We are going to win! wohoo

Dependencies:   mbed mbed-rtos

Committer:
madcowswe
Date:
Wed Nov 14 17:15:53 2012 +0000
Revision:
9:08552997b544
Parent:
1:6799c07fe510
Added an important comment

Who changed what in which revision?

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