Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Wed Oct 17 22:22:47 2012 +0000
Revision:
26:0995f61cb7b8
Parent:
25:143b19c1fb05
Eurobot 2012 Primary;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
narshu 25:143b19c1fb05 1 /*
narshu 25:143b19c1fb05 2 * Tiny Vector Matrix Library
narshu 25:143b19c1fb05 3 * Dense Vector Matrix Libary of Tiny size using Expression Templates
narshu 25:143b19c1fb05 4 *
narshu 25:143b19c1fb05 5 * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
narshu 25:143b19c1fb05 6 *
narshu 25:143b19c1fb05 7 * This library is free software; you can redistribute it and/or
narshu 25:143b19c1fb05 8 * modify it under the terms of the GNU Lesser General Public
narshu 25:143b19c1fb05 9 * License as published by the Free Software Foundation; either
narshu 25:143b19c1fb05 10 * version 2.1 of the License, or (at your option) any later version.
narshu 25:143b19c1fb05 11 *
narshu 25:143b19c1fb05 12 * This library is distributed in the hope that it will be useful,
narshu 25:143b19c1fb05 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
narshu 25:143b19c1fb05 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
narshu 25:143b19c1fb05 15 * Lesser General Public License for more details.
narshu 25:143b19c1fb05 16 *
narshu 25:143b19c1fb05 17 * You should have received a copy of the GNU Lesser General Public
narshu 25:143b19c1fb05 18 * License along with this library; if not, write to the Free Software
narshu 25:143b19c1fb05 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
narshu 25:143b19c1fb05 20 *
narshu 25:143b19c1fb05 21 * $Id: VectorUnaryFunctions.h,v 1.13 2007-06-23 15:58:58 opetzold Exp $
narshu 25:143b19c1fb05 22 */
narshu 25:143b19c1fb05 23
narshu 25:143b19c1fb05 24 #ifndef TVMET_VECTOR_UNARY_FUNCTIONS_H
narshu 25:143b19c1fb05 25 #define TVMET_VECTOR_UNARY_FUNCTIONS_H
narshu 25:143b19c1fb05 26
narshu 25:143b19c1fb05 27 namespace tvmet {
narshu 25:143b19c1fb05 28
narshu 25:143b19c1fb05 29
narshu 25:143b19c1fb05 30 /*********************************************************
narshu 25:143b19c1fb05 31 * PART I: DECLARATION
narshu 25:143b19c1fb05 32 *********************************************************/
narshu 25:143b19c1fb05 33
narshu 25:143b19c1fb05 34 /*
narshu 25:143b19c1fb05 35 * unary_function(Vector<T, Sz>)
narshu 25:143b19c1fb05 36 */
narshu 25:143b19c1fb05 37 #define TVMET_DECLARE_MACRO(NAME) \
narshu 25:143b19c1fb05 38 template<class T, std::size_t Sz> \
narshu 25:143b19c1fb05 39 XprVector< \
narshu 25:143b19c1fb05 40 XprUnOp< \
narshu 25:143b19c1fb05 41 Fcnl_##NAME<T>, \
narshu 25:143b19c1fb05 42 VectorConstReference<T, Sz> \
narshu 25:143b19c1fb05 43 >, \
narshu 25:143b19c1fb05 44 Sz \
narshu 25:143b19c1fb05 45 > \
narshu 25:143b19c1fb05 46 NAME(const Vector<T, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 25:143b19c1fb05 47
narshu 25:143b19c1fb05 48 TVMET_DECLARE_MACRO(abs)
narshu 25:143b19c1fb05 49 TVMET_DECLARE_MACRO(cbrt)
narshu 25:143b19c1fb05 50 TVMET_DECLARE_MACRO(ceil)
narshu 25:143b19c1fb05 51 TVMET_DECLARE_MACRO(floor)
narshu 25:143b19c1fb05 52 TVMET_DECLARE_MACRO(rint)
narshu 25:143b19c1fb05 53 TVMET_DECLARE_MACRO(sin)
narshu 25:143b19c1fb05 54 TVMET_DECLARE_MACRO(cos)
narshu 25:143b19c1fb05 55 TVMET_DECLARE_MACRO(tan)
narshu 25:143b19c1fb05 56 TVMET_DECLARE_MACRO(sinh)
narshu 25:143b19c1fb05 57 TVMET_DECLARE_MACRO(cosh)
narshu 25:143b19c1fb05 58 TVMET_DECLARE_MACRO(tanh)
narshu 25:143b19c1fb05 59 TVMET_DECLARE_MACRO(asin)
narshu 25:143b19c1fb05 60 TVMET_DECLARE_MACRO(acos)
narshu 25:143b19c1fb05 61 TVMET_DECLARE_MACRO(atan)
narshu 25:143b19c1fb05 62 TVMET_DECLARE_MACRO(exp)
narshu 25:143b19c1fb05 63 TVMET_DECLARE_MACRO(log)
narshu 25:143b19c1fb05 64 TVMET_DECLARE_MACRO(log10)
narshu 25:143b19c1fb05 65 TVMET_DECLARE_MACRO(sqrt)
narshu 25:143b19c1fb05 66
narshu 25:143b19c1fb05 67 #if defined(TVMET_HAVE_IEEE_MATH)
narshu 25:143b19c1fb05 68 TVMET_DECLARE_MACRO(asinh)
narshu 25:143b19c1fb05 69 TVMET_DECLARE_MACRO(acosh)
narshu 25:143b19c1fb05 70 TVMET_DECLARE_MACRO(atanh)
narshu 25:143b19c1fb05 71 TVMET_DECLARE_MACRO(expm1)
narshu 25:143b19c1fb05 72 TVMET_DECLARE_MACRO(log1p)
narshu 25:143b19c1fb05 73 TVMET_DECLARE_MACRO(erf)
narshu 25:143b19c1fb05 74 TVMET_DECLARE_MACRO(erfc)
narshu 25:143b19c1fb05 75 TVMET_DECLARE_MACRO(j0)
narshu 25:143b19c1fb05 76 TVMET_DECLARE_MACRO(j1)
narshu 25:143b19c1fb05 77 TVMET_DECLARE_MACRO(y0)
narshu 25:143b19c1fb05 78 TVMET_DECLARE_MACRO(y1)
narshu 25:143b19c1fb05 79 TVMET_DECLARE_MACRO(lgamma)
narshu 25:143b19c1fb05 80 /** \todo isnan etc. - default return is only an int! */
narshu 25:143b19c1fb05 81
narshu 25:143b19c1fb05 82 TVMET_DECLARE_MACRO(finite)
narshu 25:143b19c1fb05 83 #endif // defined(TVMET_HAVE_IEEE_MATH)
narshu 25:143b19c1fb05 84
narshu 25:143b19c1fb05 85 #undef TVMET_DECLARE_MACRO
narshu 25:143b19c1fb05 86
narshu 25:143b19c1fb05 87
narshu 25:143b19c1fb05 88 /*
narshu 25:143b19c1fb05 89 * unary_function(Vector<std::complex<T>, Sz>)
narshu 25:143b19c1fb05 90 */
narshu 25:143b19c1fb05 91 #if defined(TVMET_HAVE_COMPLEX)
narshu 25:143b19c1fb05 92 #define TVMET_DECLARE_MACRO(NAME) \
narshu 25:143b19c1fb05 93 template<class T, std::size_t Sz> \
narshu 25:143b19c1fb05 94 XprVector< \
narshu 25:143b19c1fb05 95 XprUnOp< \
narshu 25:143b19c1fb05 96 Fcnl_##NAME< std::complex<T> >, \
narshu 25:143b19c1fb05 97 VectorConstReference<std::complex<T>, Sz> \
narshu 25:143b19c1fb05 98 >, \
narshu 25:143b19c1fb05 99 Sz \
narshu 25:143b19c1fb05 100 > \
narshu 25:143b19c1fb05 101 NAME(const Vector<std::complex<T>, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 25:143b19c1fb05 102
narshu 25:143b19c1fb05 103 TVMET_DECLARE_MACRO(real)
narshu 25:143b19c1fb05 104 TVMET_DECLARE_MACRO(imag)
narshu 25:143b19c1fb05 105 TVMET_DECLARE_MACRO(arg)
narshu 25:143b19c1fb05 106 TVMET_DECLARE_MACRO(norm)
narshu 25:143b19c1fb05 107 TVMET_DECLARE_MACRO(conj)
narshu 25:143b19c1fb05 108
narshu 25:143b19c1fb05 109 #undef TVMET_DECLARE_MACRO
narshu 25:143b19c1fb05 110
narshu 25:143b19c1fb05 111 #endif // defined(TVMET_HAVE_COMPLEX)
narshu 25:143b19c1fb05 112
narshu 25:143b19c1fb05 113
narshu 25:143b19c1fb05 114 /*********************************************************
narshu 25:143b19c1fb05 115 * PART II: IMPLEMENTATION
narshu 25:143b19c1fb05 116 *********************************************************/
narshu 25:143b19c1fb05 117
narshu 25:143b19c1fb05 118
narshu 25:143b19c1fb05 119 /*
narshu 25:143b19c1fb05 120 * unary_function(Vector<T, Sz>)
narshu 25:143b19c1fb05 121 */
narshu 25:143b19c1fb05 122 #define TVMET_IMPLEMENT_MACRO(NAME) \
narshu 25:143b19c1fb05 123 template<class T, std::size_t Sz> \
narshu 25:143b19c1fb05 124 inline \
narshu 25:143b19c1fb05 125 XprVector< \
narshu 25:143b19c1fb05 126 XprUnOp< \
narshu 25:143b19c1fb05 127 Fcnl_##NAME<T>, \
narshu 25:143b19c1fb05 128 VectorConstReference<T, Sz> \
narshu 25:143b19c1fb05 129 >, \
narshu 25:143b19c1fb05 130 Sz \
narshu 25:143b19c1fb05 131 > \
narshu 25:143b19c1fb05 132 NAME(const Vector<T, Sz>& rhs) { \
narshu 25:143b19c1fb05 133 typedef XprUnOp< \
narshu 25:143b19c1fb05 134 Fcnl_##NAME<T>, \
narshu 25:143b19c1fb05 135 VectorConstReference<T, Sz> \
narshu 25:143b19c1fb05 136 > expr_type; \
narshu 25:143b19c1fb05 137 return XprVector<expr_type, Sz>(expr_type(rhs.const_ref())); \
narshu 25:143b19c1fb05 138 }
narshu 25:143b19c1fb05 139
narshu 25:143b19c1fb05 140 TVMET_IMPLEMENT_MACRO(abs)
narshu 25:143b19c1fb05 141 TVMET_IMPLEMENT_MACRO(cbrt)
narshu 25:143b19c1fb05 142 TVMET_IMPLEMENT_MACRO(ceil)
narshu 25:143b19c1fb05 143 TVMET_IMPLEMENT_MACRO(floor)
narshu 25:143b19c1fb05 144 TVMET_IMPLEMENT_MACRO(rint)
narshu 25:143b19c1fb05 145 TVMET_IMPLEMENT_MACRO(sin)
narshu 25:143b19c1fb05 146 TVMET_IMPLEMENT_MACRO(cos)
narshu 25:143b19c1fb05 147 TVMET_IMPLEMENT_MACRO(tan)
narshu 25:143b19c1fb05 148 TVMET_IMPLEMENT_MACRO(sinh)
narshu 25:143b19c1fb05 149 TVMET_IMPLEMENT_MACRO(cosh)
narshu 25:143b19c1fb05 150 TVMET_IMPLEMENT_MACRO(tanh)
narshu 25:143b19c1fb05 151 TVMET_IMPLEMENT_MACRO(asin)
narshu 25:143b19c1fb05 152 TVMET_IMPLEMENT_MACRO(acos)
narshu 25:143b19c1fb05 153 TVMET_IMPLEMENT_MACRO(atan)
narshu 25:143b19c1fb05 154 TVMET_IMPLEMENT_MACRO(exp)
narshu 25:143b19c1fb05 155 TVMET_IMPLEMENT_MACRO(log)
narshu 25:143b19c1fb05 156 TVMET_IMPLEMENT_MACRO(log10)
narshu 25:143b19c1fb05 157 TVMET_IMPLEMENT_MACRO(sqrt)
narshu 25:143b19c1fb05 158
narshu 25:143b19c1fb05 159 #if defined(TVMET_HAVE_IEEE_MATH)
narshu 25:143b19c1fb05 160 TVMET_IMPLEMENT_MACRO(asinh)
narshu 25:143b19c1fb05 161 TVMET_IMPLEMENT_MACRO(acosh)
narshu 25:143b19c1fb05 162 TVMET_IMPLEMENT_MACRO(atanh)
narshu 25:143b19c1fb05 163 TVMET_IMPLEMENT_MACRO(expm1)
narshu 25:143b19c1fb05 164 TVMET_IMPLEMENT_MACRO(log1p)
narshu 25:143b19c1fb05 165 TVMET_IMPLEMENT_MACRO(erf)
narshu 25:143b19c1fb05 166 TVMET_IMPLEMENT_MACRO(erfc)
narshu 25:143b19c1fb05 167 TVMET_IMPLEMENT_MACRO(j0)
narshu 25:143b19c1fb05 168 TVMET_IMPLEMENT_MACRO(j1)
narshu 25:143b19c1fb05 169 TVMET_IMPLEMENT_MACRO(y0)
narshu 25:143b19c1fb05 170 TVMET_IMPLEMENT_MACRO(y1)
narshu 25:143b19c1fb05 171 TVMET_IMPLEMENT_MACRO(lgamma)
narshu 25:143b19c1fb05 172 /** \todo isnan etc. - default return is only an int! */
narshu 25:143b19c1fb05 173
narshu 25:143b19c1fb05 174 TVMET_IMPLEMENT_MACRO(finite)
narshu 25:143b19c1fb05 175 #endif // defined(TVMET_HAVE_IEEE_MATH)
narshu 25:143b19c1fb05 176
narshu 25:143b19c1fb05 177 #undef TVMET_IMPLEMENT_MACRO
narshu 25:143b19c1fb05 178
narshu 25:143b19c1fb05 179
narshu 25:143b19c1fb05 180 /*
narshu 25:143b19c1fb05 181 * unary_function(Vector<std::complex<T>, Sz>)
narshu 25:143b19c1fb05 182 */
narshu 25:143b19c1fb05 183 #if defined(TVMET_HAVE_COMPLEX)
narshu 25:143b19c1fb05 184 #define TVMET_IMPLEMENT_MACRO(NAME) \
narshu 25:143b19c1fb05 185 template<class T, std::size_t Sz> \
narshu 25:143b19c1fb05 186 inline \
narshu 25:143b19c1fb05 187 XprVector< \
narshu 25:143b19c1fb05 188 XprUnOp< \
narshu 25:143b19c1fb05 189 Fcnl_##NAME< std::complex<T> >, \
narshu 25:143b19c1fb05 190 VectorConstReference<std::complex<T>, Sz> \
narshu 25:143b19c1fb05 191 >, \
narshu 25:143b19c1fb05 192 Sz \
narshu 25:143b19c1fb05 193 > \
narshu 25:143b19c1fb05 194 NAME(const Vector<std::complex<T>, Sz>& rhs) { \
narshu 25:143b19c1fb05 195 typedef XprUnOp< \
narshu 25:143b19c1fb05 196 Fcnl_##NAME< std::complex<T> >, \
narshu 25:143b19c1fb05 197 VectorConstReference<std::complex<T>, Sz> \
narshu 25:143b19c1fb05 198 > expr_type; \
narshu 25:143b19c1fb05 199 return XprVector<expr_type, Sz>(expr_type(rhs.const_ref())); \
narshu 25:143b19c1fb05 200 }
narshu 25:143b19c1fb05 201
narshu 25:143b19c1fb05 202 TVMET_IMPLEMENT_MACRO(real)
narshu 25:143b19c1fb05 203 TVMET_IMPLEMENT_MACRO(imag)
narshu 25:143b19c1fb05 204 TVMET_IMPLEMENT_MACRO(arg)
narshu 25:143b19c1fb05 205 TVMET_IMPLEMENT_MACRO(norm)
narshu 25:143b19c1fb05 206 TVMET_IMPLEMENT_MACRO(conj)
narshu 25:143b19c1fb05 207
narshu 25:143b19c1fb05 208 #undef TVMET_IMPLEMENT_MACRO
narshu 25:143b19c1fb05 209
narshu 25:143b19c1fb05 210 #endif // defined(TVMET_HAVE_COMPLEX)
narshu 25:143b19c1fb05 211
narshu 25:143b19c1fb05 212
narshu 25:143b19c1fb05 213 } // namespace tvmet
narshu 25:143b19c1fb05 214
narshu 25:143b19c1fb05 215 #endif // TVMET_VECTOR_UNARY_FUNCTIONS_H
narshu 25:143b19c1fb05 216
narshu 25:143b19c1fb05 217 // Local Variables:
narshu 25:143b19c1fb05 218 // mode:C++
narshu 25:143b19c1fb05 219 // tab-width:8
narshu 25:143b19c1fb05 220 // End: