Oskar Weigl
/
Eurobot2013
We are going to win! wohoo
tvmet/MatrixUnaryFunctions.h@9:08552997b544, 2012-11-14 (annotated)
- 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?
User | Revision | Line number | New 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: MatrixUnaryFunctions.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_MATRIX_UNARY_FUNCTIONS_H |
sv | 1:6799c07fe510 | 25 | #define TVMET_MATRIX_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(Matrix<T, Rows, Cols>) |
sv | 1:6799c07fe510 | 36 | */ |
sv | 1:6799c07fe510 | 37 | #define TVMET_DECLARE_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 38 | template<class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 39 | inline \ |
sv | 1:6799c07fe510 | 40 | XprMatrix< \ |
sv | 1:6799c07fe510 | 41 | XprUnOp< \ |
sv | 1:6799c07fe510 | 42 | Fcnl_##NAME<T>, \ |
sv | 1:6799c07fe510 | 43 | MatrixConstReference<T, Rows, Cols> \ |
sv | 1:6799c07fe510 | 44 | >, \ |
sv | 1:6799c07fe510 | 45 | Rows, Cols \ |
sv | 1:6799c07fe510 | 46 | > \ |
sv | 1:6799c07fe510 | 47 | NAME(const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 48 | |
sv | 1:6799c07fe510 | 49 | TVMET_DECLARE_MACRO(abs) |
sv | 1:6799c07fe510 | 50 | TVMET_DECLARE_MACRO(cbrt) |
sv | 1:6799c07fe510 | 51 | TVMET_DECLARE_MACRO(ceil) |
sv | 1:6799c07fe510 | 52 | TVMET_DECLARE_MACRO(floor) |
sv | 1:6799c07fe510 | 53 | TVMET_DECLARE_MACRO(rint) |
sv | 1:6799c07fe510 | 54 | TVMET_DECLARE_MACRO(sin) |
sv | 1:6799c07fe510 | 55 | TVMET_DECLARE_MACRO(cos) |
sv | 1:6799c07fe510 | 56 | TVMET_DECLARE_MACRO(tan) |
sv | 1:6799c07fe510 | 57 | TVMET_DECLARE_MACRO(sinh) |
sv | 1:6799c07fe510 | 58 | TVMET_DECLARE_MACRO(cosh) |
sv | 1:6799c07fe510 | 59 | TVMET_DECLARE_MACRO(tanh) |
sv | 1:6799c07fe510 | 60 | TVMET_DECLARE_MACRO(asin) |
sv | 1:6799c07fe510 | 61 | TVMET_DECLARE_MACRO(acos) |
sv | 1:6799c07fe510 | 62 | TVMET_DECLARE_MACRO(atan) |
sv | 1:6799c07fe510 | 63 | TVMET_DECLARE_MACRO(exp) |
sv | 1:6799c07fe510 | 64 | TVMET_DECLARE_MACRO(log) |
sv | 1:6799c07fe510 | 65 | TVMET_DECLARE_MACRO(log10) |
sv | 1:6799c07fe510 | 66 | TVMET_DECLARE_MACRO(sqrt) |
sv | 1:6799c07fe510 | 67 | |
sv | 1:6799c07fe510 | 68 | #if defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 69 | TVMET_DECLARE_MACRO(asinh) |
sv | 1:6799c07fe510 | 70 | TVMET_DECLARE_MACRO(acosh) |
sv | 1:6799c07fe510 | 71 | TVMET_DECLARE_MACRO(atanh) |
sv | 1:6799c07fe510 | 72 | TVMET_DECLARE_MACRO(expm1) |
sv | 1:6799c07fe510 | 73 | TVMET_DECLARE_MACRO(log1p) |
sv | 1:6799c07fe510 | 74 | TVMET_DECLARE_MACRO(erf) |
sv | 1:6799c07fe510 | 75 | TVMET_DECLARE_MACRO(erfc) |
sv | 1:6799c07fe510 | 76 | TVMET_DECLARE_MACRO(j0) |
sv | 1:6799c07fe510 | 77 | TVMET_DECLARE_MACRO(j1) |
sv | 1:6799c07fe510 | 78 | TVMET_DECLARE_MACRO(y0) |
sv | 1:6799c07fe510 | 79 | TVMET_DECLARE_MACRO(y1) |
sv | 1:6799c07fe510 | 80 | TVMET_DECLARE_MACRO(lgamma) |
sv | 1:6799c07fe510 | 81 | /** \todo isnan etc. - default return is only an int! */ |
sv | 1:6799c07fe510 | 82 | |
sv | 1:6799c07fe510 | 83 | TVMET_DECLARE_MACRO(finite) |
sv | 1:6799c07fe510 | 84 | #endif // defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 85 | |
sv | 1:6799c07fe510 | 86 | #undef TVMET_DECLARE_MACRO |
sv | 1:6799c07fe510 | 87 | |
sv | 1:6799c07fe510 | 88 | |
sv | 1:6799c07fe510 | 89 | /* |
sv | 1:6799c07fe510 | 90 | * unary_function(Matrix<std::complex<T>, Rows, Cols>) |
sv | 1:6799c07fe510 | 91 | */ |
sv | 1:6799c07fe510 | 92 | #if defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 93 | #define TVMET_DECLARE_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 94 | template<class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 95 | inline \ |
sv | 1:6799c07fe510 | 96 | XprMatrix< \ |
sv | 1:6799c07fe510 | 97 | XprUnOp< \ |
sv | 1:6799c07fe510 | 98 | Fcnl_##NAME< std::complex<T> >, \ |
sv | 1:6799c07fe510 | 99 | MatrixConstReference<std::complex<T>, Rows, Cols> \ |
sv | 1:6799c07fe510 | 100 | >, \ |
sv | 1:6799c07fe510 | 101 | Rows, Cols \ |
sv | 1:6799c07fe510 | 102 | > \ |
sv | 1:6799c07fe510 | 103 | NAME(const Matrix<std::complex<T>, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 104 | |
sv | 1:6799c07fe510 | 105 | TVMET_DECLARE_MACRO(real) |
sv | 1:6799c07fe510 | 106 | TVMET_DECLARE_MACRO(imag) |
sv | 1:6799c07fe510 | 107 | TVMET_DECLARE_MACRO(arg) |
sv | 1:6799c07fe510 | 108 | TVMET_DECLARE_MACRO(norm) |
sv | 1:6799c07fe510 | 109 | TVMET_DECLARE_MACRO(conj) |
sv | 1:6799c07fe510 | 110 | |
sv | 1:6799c07fe510 | 111 | #undef TVMET_DECLARE_MACRO |
sv | 1:6799c07fe510 | 112 | |
sv | 1:6799c07fe510 | 113 | #endif // defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 114 | |
sv | 1:6799c07fe510 | 115 | |
sv | 1:6799c07fe510 | 116 | /********************************************************* |
sv | 1:6799c07fe510 | 117 | * PART II: IMPLEMENTATION |
sv | 1:6799c07fe510 | 118 | *********************************************************/ |
sv | 1:6799c07fe510 | 119 | |
sv | 1:6799c07fe510 | 120 | |
sv | 1:6799c07fe510 | 121 | /* |
sv | 1:6799c07fe510 | 122 | * unary_function(Matrix<T, Rows, Cols>) |
sv | 1:6799c07fe510 | 123 | */ |
sv | 1:6799c07fe510 | 124 | #define TVMET_IMPLEMENT_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 125 | template<class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 126 | inline \ |
sv | 1:6799c07fe510 | 127 | XprMatrix< \ |
sv | 1:6799c07fe510 | 128 | XprUnOp< \ |
sv | 1:6799c07fe510 | 129 | Fcnl_##NAME<T>, \ |
sv | 1:6799c07fe510 | 130 | MatrixConstReference<T, Rows, Cols> \ |
sv | 1:6799c07fe510 | 131 | >, \ |
sv | 1:6799c07fe510 | 132 | Rows, Cols \ |
sv | 1:6799c07fe510 | 133 | > \ |
sv | 1:6799c07fe510 | 134 | NAME(const Matrix<T, Rows, Cols>& rhs) { \ |
sv | 1:6799c07fe510 | 135 | typedef XprUnOp< \ |
sv | 1:6799c07fe510 | 136 | Fcnl_##NAME<T>, \ |
sv | 1:6799c07fe510 | 137 | MatrixConstReference<T, Rows, Cols> \ |
sv | 1:6799c07fe510 | 138 | > expr_type; \ |
sv | 1:6799c07fe510 | 139 | return XprMatrix<expr_type, Rows, Cols>(expr_type(rhs.const_ref())); \ |
sv | 1:6799c07fe510 | 140 | } |
sv | 1:6799c07fe510 | 141 | |
sv | 1:6799c07fe510 | 142 | TVMET_IMPLEMENT_MACRO(abs) |
sv | 1:6799c07fe510 | 143 | TVMET_IMPLEMENT_MACRO(cbrt) |
sv | 1:6799c07fe510 | 144 | TVMET_IMPLEMENT_MACRO(ceil) |
sv | 1:6799c07fe510 | 145 | TVMET_IMPLEMENT_MACRO(floor) |
sv | 1:6799c07fe510 | 146 | TVMET_IMPLEMENT_MACRO(rint) |
sv | 1:6799c07fe510 | 147 | TVMET_IMPLEMENT_MACRO(sin) |
sv | 1:6799c07fe510 | 148 | TVMET_IMPLEMENT_MACRO(cos) |
sv | 1:6799c07fe510 | 149 | TVMET_IMPLEMENT_MACRO(tan) |
sv | 1:6799c07fe510 | 150 | TVMET_IMPLEMENT_MACRO(sinh) |
sv | 1:6799c07fe510 | 151 | TVMET_IMPLEMENT_MACRO(cosh) |
sv | 1:6799c07fe510 | 152 | TVMET_IMPLEMENT_MACRO(tanh) |
sv | 1:6799c07fe510 | 153 | TVMET_IMPLEMENT_MACRO(asin) |
sv | 1:6799c07fe510 | 154 | TVMET_IMPLEMENT_MACRO(acos) |
sv | 1:6799c07fe510 | 155 | TVMET_IMPLEMENT_MACRO(atan) |
sv | 1:6799c07fe510 | 156 | TVMET_IMPLEMENT_MACRO(exp) |
sv | 1:6799c07fe510 | 157 | TVMET_IMPLEMENT_MACRO(log) |
sv | 1:6799c07fe510 | 158 | TVMET_IMPLEMENT_MACRO(log10) |
sv | 1:6799c07fe510 | 159 | TVMET_IMPLEMENT_MACRO(sqrt) |
sv | 1:6799c07fe510 | 160 | |
sv | 1:6799c07fe510 | 161 | #if defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 162 | TVMET_IMPLEMENT_MACRO(asinh) |
sv | 1:6799c07fe510 | 163 | TVMET_IMPLEMENT_MACRO(acosh) |
sv | 1:6799c07fe510 | 164 | TVMET_IMPLEMENT_MACRO(atanh) |
sv | 1:6799c07fe510 | 165 | TVMET_IMPLEMENT_MACRO(expm1) |
sv | 1:6799c07fe510 | 166 | TVMET_IMPLEMENT_MACRO(log1p) |
sv | 1:6799c07fe510 | 167 | TVMET_IMPLEMENT_MACRO(erf) |
sv | 1:6799c07fe510 | 168 | TVMET_IMPLEMENT_MACRO(erfc) |
sv | 1:6799c07fe510 | 169 | TVMET_IMPLEMENT_MACRO(j0) |
sv | 1:6799c07fe510 | 170 | TVMET_IMPLEMENT_MACRO(j1) |
sv | 1:6799c07fe510 | 171 | TVMET_IMPLEMENT_MACRO(y0) |
sv | 1:6799c07fe510 | 172 | TVMET_IMPLEMENT_MACRO(y1) |
sv | 1:6799c07fe510 | 173 | TVMET_IMPLEMENT_MACRO(lgamma) |
sv | 1:6799c07fe510 | 174 | /** \todo isnan etc. - default return is only an int! */ |
sv | 1:6799c07fe510 | 175 | |
sv | 1:6799c07fe510 | 176 | TVMET_IMPLEMENT_MACRO(finite) |
sv | 1:6799c07fe510 | 177 | #endif // defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 178 | |
sv | 1:6799c07fe510 | 179 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 180 | |
sv | 1:6799c07fe510 | 181 | |
sv | 1:6799c07fe510 | 182 | /* |
sv | 1:6799c07fe510 | 183 | * unary_function(Matrix<std::complex<T>, Rows, Cols>) |
sv | 1:6799c07fe510 | 184 | */ |
sv | 1:6799c07fe510 | 185 | #if defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 186 | #define TVMET_IMPLEMENT_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 187 | template<class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 188 | inline \ |
sv | 1:6799c07fe510 | 189 | XprMatrix< \ |
sv | 1:6799c07fe510 | 190 | XprUnOp< \ |
sv | 1:6799c07fe510 | 191 | Fcnl_##NAME< std::complex<T> >, \ |
sv | 1:6799c07fe510 | 192 | MatrixConstReference<std::complex<T>, Rows, Cols> \ |
sv | 1:6799c07fe510 | 193 | >, \ |
sv | 1:6799c07fe510 | 194 | Rows, Cols \ |
sv | 1:6799c07fe510 | 195 | > \ |
sv | 1:6799c07fe510 | 196 | NAME(const Matrix<std::complex<T>, Rows, Cols>& rhs) { \ |
sv | 1:6799c07fe510 | 197 | typedef XprUnOp< \ |
sv | 1:6799c07fe510 | 198 | Fcnl_##NAME< std::complex<T> >, \ |
sv | 1:6799c07fe510 | 199 | MatrixConstReference<std::complex<T>, Rows, Cols> \ |
sv | 1:6799c07fe510 | 200 | > expr_type; \ |
sv | 1:6799c07fe510 | 201 | return XprMatrix<expr_type, Rows, Cols>(expr_type(rhs.const_ref())); \ |
sv | 1:6799c07fe510 | 202 | } |
sv | 1:6799c07fe510 | 203 | |
sv | 1:6799c07fe510 | 204 | TVMET_IMPLEMENT_MACRO(real) |
sv | 1:6799c07fe510 | 205 | TVMET_IMPLEMENT_MACRO(imag) |
sv | 1:6799c07fe510 | 206 | TVMET_IMPLEMENT_MACRO(arg) |
sv | 1:6799c07fe510 | 207 | TVMET_IMPLEMENT_MACRO(norm) |
sv | 1:6799c07fe510 | 208 | TVMET_IMPLEMENT_MACRO(conj) |
sv | 1:6799c07fe510 | 209 | |
sv | 1:6799c07fe510 | 210 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 211 | |
sv | 1:6799c07fe510 | 212 | #endif // defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 213 | |
sv | 1:6799c07fe510 | 214 | |
sv | 1:6799c07fe510 | 215 | } // namespace tvmet |
sv | 1:6799c07fe510 | 216 | |
sv | 1:6799c07fe510 | 217 | #endif // TVMET_MATRIX_UNARY_FUNCTIONS_H |
sv | 1:6799c07fe510 | 218 | |
sv | 1:6799c07fe510 | 219 | // Local Variables: |
sv | 1:6799c07fe510 | 220 | // mode:C++ |
sv | 1:6799c07fe510 | 221 | // tab-width:8 |
sv | 1:6799c07fe510 | 222 | // End: |