Oskar Weigl
/
Eurobot2013
We are going to win! wohoo
tvmet/MatrixBinaryFunctions.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: MatrixBinaryFunctions.h,v 1.16 2007-06-23 15:58:58 opetzold Exp $ |
sv | 1:6799c07fe510 | 22 | */ |
sv | 1:6799c07fe510 | 23 | |
sv | 1:6799c07fe510 | 24 | #ifndef TVMET_MATRIX_BINARY_FUNCTIONS_H |
sv | 1:6799c07fe510 | 25 | #define TVMET_MATRIX_BINARY_FUNCTIONS_H |
sv | 1:6799c07fe510 | 26 | |
sv | 1:6799c07fe510 | 27 | namespace tvmet { |
sv | 1:6799c07fe510 | 28 | |
sv | 1:6799c07fe510 | 29 | /********************************************************* |
sv | 1:6799c07fe510 | 30 | * PART I: DECLARATION |
sv | 1:6799c07fe510 | 31 | *********************************************************/ |
sv | 1:6799c07fe510 | 32 | |
sv | 1:6799c07fe510 | 33 | /* |
sv | 1:6799c07fe510 | 34 | * binary_function(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>) |
sv | 1:6799c07fe510 | 35 | * binary_function(Matrix<T1, Rows, Cols>, XprMatrix<E, Rows, Cols>) |
sv | 1:6799c07fe510 | 36 | * binary_function(XprMatrix<E, Rows, Cols>, Matrix<T, Rows, Cols>) |
sv | 1:6799c07fe510 | 37 | */ |
sv | 1:6799c07fe510 | 38 | #define TVMET_DECLARE_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 39 | template<class T1, class T2, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 40 | XprMatrix< \ |
sv | 1:6799c07fe510 | 41 | XprBinOp< \ |
sv | 1:6799c07fe510 | 42 | Fcnl_##NAME<T1, T2>, \ |
sv | 1:6799c07fe510 | 43 | MatrixConstReference<T1, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 44 | MatrixConstReference<T2, Rows, Cols> \ |
sv | 1:6799c07fe510 | 45 | >, \ |
sv | 1:6799c07fe510 | 46 | Rows, Cols \ |
sv | 1:6799c07fe510 | 47 | > \ |
sv | 1:6799c07fe510 | 48 | NAME(const Matrix<T1, Rows, Cols>& lhs, \ |
sv | 1:6799c07fe510 | 49 | const Matrix<T2, Cols, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \ |
sv | 1:6799c07fe510 | 50 | \ |
sv | 1:6799c07fe510 | 51 | template<class E, class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 52 | XprMatrix< \ |
sv | 1:6799c07fe510 | 53 | XprBinOp< \ |
sv | 1:6799c07fe510 | 54 | Fcnl_##NAME<typename E::value_type, T>, \ |
sv | 1:6799c07fe510 | 55 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 56 | XprMatrix<E, Rows, Cols> \ |
sv | 1:6799c07fe510 | 57 | >, \ |
sv | 1:6799c07fe510 | 58 | Rows, Cols \ |
sv | 1:6799c07fe510 | 59 | > \ |
sv | 1:6799c07fe510 | 60 | NAME(const XprMatrix<E, Rows, Cols>& lhs, \ |
sv | 1:6799c07fe510 | 61 | const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \ |
sv | 1:6799c07fe510 | 62 | \ |
sv | 1:6799c07fe510 | 63 | template<class E, class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 64 | XprMatrix< \ |
sv | 1:6799c07fe510 | 65 | XprBinOp< \ |
sv | 1:6799c07fe510 | 66 | Fcnl_##NAME<T, typename E::value_type>, \ |
sv | 1:6799c07fe510 | 67 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 68 | XprMatrix<E, Rows, Cols> \ |
sv | 1:6799c07fe510 | 69 | >, \ |
sv | 1:6799c07fe510 | 70 | Rows, Cols \ |
sv | 1:6799c07fe510 | 71 | > \ |
sv | 1:6799c07fe510 | 72 | NAME(const Matrix<T, Rows, Cols>& lhs, \ |
sv | 1:6799c07fe510 | 73 | const XprMatrix<E, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 74 | |
sv | 1:6799c07fe510 | 75 | TVMET_DECLARE_MACRO(atan2) |
sv | 1:6799c07fe510 | 76 | TVMET_DECLARE_MACRO(drem) |
sv | 1:6799c07fe510 | 77 | TVMET_DECLARE_MACRO(fmod) |
sv | 1:6799c07fe510 | 78 | TVMET_DECLARE_MACRO(hypot) |
sv | 1:6799c07fe510 | 79 | TVMET_DECLARE_MACRO(jn) |
sv | 1:6799c07fe510 | 80 | TVMET_DECLARE_MACRO(yn) |
sv | 1:6799c07fe510 | 81 | TVMET_DECLARE_MACRO(pow) |
sv | 1:6799c07fe510 | 82 | #if defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 83 | TVMET_DECLARE_MACRO(polar) |
sv | 1:6799c07fe510 | 84 | #endif |
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 | * binary_function(Matrix<T, Rows, Cols>, POD) |
sv | 1:6799c07fe510 | 91 | */ |
sv | 1:6799c07fe510 | 92 | #define TVMET_DECLARE_MACRO(NAME, TP) \ |
sv | 1:6799c07fe510 | 93 | template<class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 94 | XprMatrix< \ |
sv | 1:6799c07fe510 | 95 | XprBinOp< \ |
sv | 1:6799c07fe510 | 96 | Fcnl_##NAME<T, TP >, \ |
sv | 1:6799c07fe510 | 97 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 98 | XprLiteral< TP > \ |
sv | 1:6799c07fe510 | 99 | >, \ |
sv | 1:6799c07fe510 | 100 | Rows, Cols \ |
sv | 1:6799c07fe510 | 101 | > \ |
sv | 1:6799c07fe510 | 102 | NAME(const Matrix<T, Rows, Cols>& lhs, TP rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 103 | |
sv | 1:6799c07fe510 | 104 | TVMET_DECLARE_MACRO(atan2, int) |
sv | 1:6799c07fe510 | 105 | TVMET_DECLARE_MACRO(drem, int) |
sv | 1:6799c07fe510 | 106 | TVMET_DECLARE_MACRO(fmod, int) |
sv | 1:6799c07fe510 | 107 | TVMET_DECLARE_MACRO(hypot, int) |
sv | 1:6799c07fe510 | 108 | TVMET_DECLARE_MACRO(jn, int) |
sv | 1:6799c07fe510 | 109 | TVMET_DECLARE_MACRO(yn, int) |
sv | 1:6799c07fe510 | 110 | TVMET_DECLARE_MACRO(pow, int) |
sv | 1:6799c07fe510 | 111 | |
sv | 1:6799c07fe510 | 112 | #if defined(TVMET_HAVE_LONG_LONG) |
sv | 1:6799c07fe510 | 113 | TVMET_DECLARE_MACRO(atan2, long long int) |
sv | 1:6799c07fe510 | 114 | TVMET_DECLARE_MACRO(drem, long long int) |
sv | 1:6799c07fe510 | 115 | TVMET_DECLARE_MACRO(fmod, long long int) |
sv | 1:6799c07fe510 | 116 | TVMET_DECLARE_MACRO(hypot, long long int) |
sv | 1:6799c07fe510 | 117 | TVMET_DECLARE_MACRO(jn, long long int) |
sv | 1:6799c07fe510 | 118 | TVMET_DECLARE_MACRO(yn, long long int) |
sv | 1:6799c07fe510 | 119 | TVMET_DECLARE_MACRO(pow, long long int) |
sv | 1:6799c07fe510 | 120 | #endif // defined(TVMET_HAVE_LONG_LONG) |
sv | 1:6799c07fe510 | 121 | |
sv | 1:6799c07fe510 | 122 | TVMET_DECLARE_MACRO(atan2, float) |
sv | 1:6799c07fe510 | 123 | TVMET_DECLARE_MACRO(drem, float) |
sv | 1:6799c07fe510 | 124 | TVMET_DECLARE_MACRO(fmod, float) |
sv | 1:6799c07fe510 | 125 | TVMET_DECLARE_MACRO(hypot, float) |
sv | 1:6799c07fe510 | 126 | TVMET_DECLARE_MACRO(jn, float) |
sv | 1:6799c07fe510 | 127 | TVMET_DECLARE_MACRO(yn, float) |
sv | 1:6799c07fe510 | 128 | TVMET_DECLARE_MACRO(pow, float) |
sv | 1:6799c07fe510 | 129 | |
sv | 1:6799c07fe510 | 130 | TVMET_DECLARE_MACRO(atan2, double) |
sv | 1:6799c07fe510 | 131 | TVMET_DECLARE_MACRO(drem, double) |
sv | 1:6799c07fe510 | 132 | TVMET_DECLARE_MACRO(fmod, double) |
sv | 1:6799c07fe510 | 133 | TVMET_DECLARE_MACRO(hypot, double) |
sv | 1:6799c07fe510 | 134 | TVMET_DECLARE_MACRO(jn, double) |
sv | 1:6799c07fe510 | 135 | TVMET_DECLARE_MACRO(yn, double) |
sv | 1:6799c07fe510 | 136 | TVMET_DECLARE_MACRO(pow, double) |
sv | 1:6799c07fe510 | 137 | |
sv | 1:6799c07fe510 | 138 | #if defined(TVMET_HAVE_LONG_DOUBLE) |
sv | 1:6799c07fe510 | 139 | TVMET_DECLARE_MACRO(atan2, long double) |
sv | 1:6799c07fe510 | 140 | TVMET_DECLARE_MACRO(drem, long double) |
sv | 1:6799c07fe510 | 141 | TVMET_DECLARE_MACRO(fmod, long double) |
sv | 1:6799c07fe510 | 142 | TVMET_DECLARE_MACRO(hypot, long double) |
sv | 1:6799c07fe510 | 143 | TVMET_DECLARE_MACRO(jn, long double) |
sv | 1:6799c07fe510 | 144 | TVMET_DECLARE_MACRO(yn, long double) |
sv | 1:6799c07fe510 | 145 | TVMET_DECLARE_MACRO(pow, long double) |
sv | 1:6799c07fe510 | 146 | #endif // defined(TVMET_HAVE_LONG_DOUBLE) |
sv | 1:6799c07fe510 | 147 | |
sv | 1:6799c07fe510 | 148 | #undef TVMET_DECLARE_MACRO |
sv | 1:6799c07fe510 | 149 | |
sv | 1:6799c07fe510 | 150 | |
sv | 1:6799c07fe510 | 151 | /* |
sv | 1:6799c07fe510 | 152 | * complex math |
sv | 1:6799c07fe510 | 153 | */ |
sv | 1:6799c07fe510 | 154 | |
sv | 1:6799c07fe510 | 155 | #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1) |
sv | 1:6799c07fe510 | 156 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 157 | XprMatrix< |
sv | 1:6799c07fe510 | 158 | XprBinOp< |
sv | 1:6799c07fe510 | 159 | Fcnl_pow<T, std::complex<T> >, |
sv | 1:6799c07fe510 | 160 | MatrixConstReference<T, Rows, Cols>, |
sv | 1:6799c07fe510 | 161 | XprLiteral< std::complex<T> > |
sv | 1:6799c07fe510 | 162 | >, |
sv | 1:6799c07fe510 | 163 | Rows, Cols |
sv | 1:6799c07fe510 | 164 | > |
sv | 1:6799c07fe510 | 165 | pow(const Matrix<T, Rows, Cols>& lhs, |
sv | 1:6799c07fe510 | 166 | const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 167 | |
sv | 1:6799c07fe510 | 168 | |
sv | 1:6799c07fe510 | 169 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 170 | XprMatrix< |
sv | 1:6799c07fe510 | 171 | XprBinOp< |
sv | 1:6799c07fe510 | 172 | Fcnl_pow< std::complex<T>, std::complex<T> >, |
sv | 1:6799c07fe510 | 173 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 174 | XprLiteral< std::complex<T> > |
sv | 1:6799c07fe510 | 175 | >, |
sv | 1:6799c07fe510 | 176 | Rows, Cols |
sv | 1:6799c07fe510 | 177 | > |
sv | 1:6799c07fe510 | 178 | pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, |
sv | 1:6799c07fe510 | 179 | const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 180 | |
sv | 1:6799c07fe510 | 181 | |
sv | 1:6799c07fe510 | 182 | /** |
sv | 1:6799c07fe510 | 183 | * \fn pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const T& rhs) |
sv | 1:6799c07fe510 | 184 | * \ingroup _binary_function |
sv | 1:6799c07fe510 | 185 | */ |
sv | 1:6799c07fe510 | 186 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 187 | XprMatrix< |
sv | 1:6799c07fe510 | 188 | XprBinOp< |
sv | 1:6799c07fe510 | 189 | Fcnl_pow<std::complex<T>, T>, |
sv | 1:6799c07fe510 | 190 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 191 | XprLiteral<T> |
sv | 1:6799c07fe510 | 192 | >, |
sv | 1:6799c07fe510 | 193 | Rows, Cols |
sv | 1:6799c07fe510 | 194 | > |
sv | 1:6799c07fe510 | 195 | pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, |
sv | 1:6799c07fe510 | 196 | const T& rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 197 | |
sv | 1:6799c07fe510 | 198 | |
sv | 1:6799c07fe510 | 199 | /** |
sv | 1:6799c07fe510 | 200 | * \fn pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, int rhs) |
sv | 1:6799c07fe510 | 201 | * \ingroup _binary_function |
sv | 1:6799c07fe510 | 202 | */ |
sv | 1:6799c07fe510 | 203 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 204 | XprMatrix< |
sv | 1:6799c07fe510 | 205 | XprBinOp< |
sv | 1:6799c07fe510 | 206 | Fcnl_pow<std::complex<T>, int>, |
sv | 1:6799c07fe510 | 207 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 208 | XprLiteral<int> |
sv | 1:6799c07fe510 | 209 | >, |
sv | 1:6799c07fe510 | 210 | Rows, Cols |
sv | 1:6799c07fe510 | 211 | > |
sv | 1:6799c07fe510 | 212 | pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, |
sv | 1:6799c07fe510 | 213 | int rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 214 | |
sv | 1:6799c07fe510 | 215 | |
sv | 1:6799c07fe510 | 216 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 217 | XprMatrix< |
sv | 1:6799c07fe510 | 218 | XprBinOp< |
sv | 1:6799c07fe510 | 219 | Fcnl_polar<T, T>, |
sv | 1:6799c07fe510 | 220 | MatrixConstReference<T, Rows, Cols>, |
sv | 1:6799c07fe510 | 221 | XprLiteral<T> |
sv | 1:6799c07fe510 | 222 | >, |
sv | 1:6799c07fe510 | 223 | Rows, Cols |
sv | 1:6799c07fe510 | 224 | > |
sv | 1:6799c07fe510 | 225 | polar(const Matrix<T, Rows, Cols>& lhs, |
sv | 1:6799c07fe510 | 226 | const T& rhs) TVMET_CXX_ALWAYS_INLINE; |
sv | 1:6799c07fe510 | 227 | |
sv | 1:6799c07fe510 | 228 | #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1) |
sv | 1:6799c07fe510 | 229 | |
sv | 1:6799c07fe510 | 230 | |
sv | 1:6799c07fe510 | 231 | #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2) |
sv | 1:6799c07fe510 | 232 | // to be written (atan2) |
sv | 1:6799c07fe510 | 233 | #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2) |
sv | 1:6799c07fe510 | 234 | |
sv | 1:6799c07fe510 | 235 | |
sv | 1:6799c07fe510 | 236 | /********************************************************* |
sv | 1:6799c07fe510 | 237 | * PART II: IMPLEMENTATION |
sv | 1:6799c07fe510 | 238 | *********************************************************/ |
sv | 1:6799c07fe510 | 239 | |
sv | 1:6799c07fe510 | 240 | /* |
sv | 1:6799c07fe510 | 241 | * binary_function(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>) |
sv | 1:6799c07fe510 | 242 | * binary_function(Matrix<T1, Rows, Cols>, XprMatrix<E, Rows, Cols>) |
sv | 1:6799c07fe510 | 243 | * binary_function(XprMatrix<E, Rows, Cols>, Matrix<T, Rows, Cols>) |
sv | 1:6799c07fe510 | 244 | */ |
sv | 1:6799c07fe510 | 245 | #define TVMET_IMPLEMENT_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 246 | template<class T1, class T2, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 247 | inline \ |
sv | 1:6799c07fe510 | 248 | XprMatrix< \ |
sv | 1:6799c07fe510 | 249 | XprBinOp< \ |
sv | 1:6799c07fe510 | 250 | Fcnl_##NAME<T1, T2>, \ |
sv | 1:6799c07fe510 | 251 | MatrixConstReference<T1, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 252 | MatrixConstReference<T2, Rows, Cols> \ |
sv | 1:6799c07fe510 | 253 | >, \ |
sv | 1:6799c07fe510 | 254 | Rows, Cols \ |
sv | 1:6799c07fe510 | 255 | > \ |
sv | 1:6799c07fe510 | 256 | NAME(const Matrix<T1, Rows, Cols>& lhs, const Matrix<T2, Cols, Cols>& rhs) { \ |
sv | 1:6799c07fe510 | 257 | typedef XprBinOp < \ |
sv | 1:6799c07fe510 | 258 | Fcnl_##NAME<T1, T2>, \ |
sv | 1:6799c07fe510 | 259 | MatrixConstReference<T1, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 260 | MatrixConstReference<T2, Rows, Cols> \ |
sv | 1:6799c07fe510 | 261 | > expr_type; \ |
sv | 1:6799c07fe510 | 262 | return XprMatrix<expr_type, Rows, Cols>( \ |
sv | 1:6799c07fe510 | 263 | expr_type(lhs.const_ref(), rhs.const_ref())); \ |
sv | 1:6799c07fe510 | 264 | } \ |
sv | 1:6799c07fe510 | 265 | \ |
sv | 1:6799c07fe510 | 266 | template<class E, class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 267 | inline \ |
sv | 1:6799c07fe510 | 268 | XprMatrix< \ |
sv | 1:6799c07fe510 | 269 | XprBinOp< \ |
sv | 1:6799c07fe510 | 270 | Fcnl_##NAME<typename E::value_type, T>, \ |
sv | 1:6799c07fe510 | 271 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 272 | XprMatrix<E, Rows, Cols> \ |
sv | 1:6799c07fe510 | 273 | >, \ |
sv | 1:6799c07fe510 | 274 | Rows, Cols \ |
sv | 1:6799c07fe510 | 275 | > \ |
sv | 1:6799c07fe510 | 276 | NAME(const XprMatrix<E, Rows, Cols>& lhs, const Matrix<T, Rows, Cols>& rhs) { \ |
sv | 1:6799c07fe510 | 277 | typedef XprBinOp< \ |
sv | 1:6799c07fe510 | 278 | Fcnl_##NAME<typename E::value_type, T>, \ |
sv | 1:6799c07fe510 | 279 | XprMatrix<E, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 280 | MatrixConstReference<T, Rows, Cols> \ |
sv | 1:6799c07fe510 | 281 | > expr_type; \ |
sv | 1:6799c07fe510 | 282 | return XprMatrix<expr_type, Rows, Cols>( \ |
sv | 1:6799c07fe510 | 283 | expr_type(lhs, rhs.const_ref())); \ |
sv | 1:6799c07fe510 | 284 | } \ |
sv | 1:6799c07fe510 | 285 | \ |
sv | 1:6799c07fe510 | 286 | template<class E, class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 287 | inline \ |
sv | 1:6799c07fe510 | 288 | XprMatrix< \ |
sv | 1:6799c07fe510 | 289 | XprBinOp< \ |
sv | 1:6799c07fe510 | 290 | Fcnl_##NAME<T, typename E::value_type>, \ |
sv | 1:6799c07fe510 | 291 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 292 | XprMatrix<E, Rows, Cols> \ |
sv | 1:6799c07fe510 | 293 | >, \ |
sv | 1:6799c07fe510 | 294 | Rows, Cols \ |
sv | 1:6799c07fe510 | 295 | > \ |
sv | 1:6799c07fe510 | 296 | NAME(const Matrix<T, Rows, Cols>& lhs, const XprMatrix<E, Rows, Cols>& rhs) { \ |
sv | 1:6799c07fe510 | 297 | typedef XprBinOp< \ |
sv | 1:6799c07fe510 | 298 | Fcnl_##NAME<T, typename E::value_type>, \ |
sv | 1:6799c07fe510 | 299 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 300 | XprMatrix<E, Rows, Cols> \ |
sv | 1:6799c07fe510 | 301 | > expr_type; \ |
sv | 1:6799c07fe510 | 302 | return XprMatrix<expr_type, Rows, Cols>( \ |
sv | 1:6799c07fe510 | 303 | expr_type(lhs.const_ref(), rhs)); \ |
sv | 1:6799c07fe510 | 304 | } |
sv | 1:6799c07fe510 | 305 | |
sv | 1:6799c07fe510 | 306 | TVMET_IMPLEMENT_MACRO(atan2) |
sv | 1:6799c07fe510 | 307 | TVMET_IMPLEMENT_MACRO(drem) |
sv | 1:6799c07fe510 | 308 | TVMET_IMPLEMENT_MACRO(fmod) |
sv | 1:6799c07fe510 | 309 | TVMET_IMPLEMENT_MACRO(hypot) |
sv | 1:6799c07fe510 | 310 | TVMET_IMPLEMENT_MACRO(jn) |
sv | 1:6799c07fe510 | 311 | TVMET_IMPLEMENT_MACRO(yn) |
sv | 1:6799c07fe510 | 312 | TVMET_IMPLEMENT_MACRO(pow) |
sv | 1:6799c07fe510 | 313 | #if defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 314 | TVMET_IMPLEMENT_MACRO(polar) |
sv | 1:6799c07fe510 | 315 | #endif |
sv | 1:6799c07fe510 | 316 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 317 | |
sv | 1:6799c07fe510 | 318 | |
sv | 1:6799c07fe510 | 319 | /* |
sv | 1:6799c07fe510 | 320 | * binary_function(Matrix<T, Rows, Cols>, POD) |
sv | 1:6799c07fe510 | 321 | */ |
sv | 1:6799c07fe510 | 322 | #define TVMET_IMPLEMENT_MACRO(NAME, TP) \ |
sv | 1:6799c07fe510 | 323 | template<class T, std::size_t Rows, std::size_t Cols> \ |
sv | 1:6799c07fe510 | 324 | inline \ |
sv | 1:6799c07fe510 | 325 | XprMatrix< \ |
sv | 1:6799c07fe510 | 326 | XprBinOp< \ |
sv | 1:6799c07fe510 | 327 | Fcnl_##NAME<T, TP >, \ |
sv | 1:6799c07fe510 | 328 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 329 | XprLiteral< TP > \ |
sv | 1:6799c07fe510 | 330 | >, \ |
sv | 1:6799c07fe510 | 331 | Rows, Cols \ |
sv | 1:6799c07fe510 | 332 | > \ |
sv | 1:6799c07fe510 | 333 | NAME(const Matrix<T, Rows, Cols>& lhs, TP rhs) { \ |
sv | 1:6799c07fe510 | 334 | typedef XprBinOp< \ |
sv | 1:6799c07fe510 | 335 | Fcnl_##NAME<T, TP >, \ |
sv | 1:6799c07fe510 | 336 | MatrixConstReference<T, Rows, Cols>, \ |
sv | 1:6799c07fe510 | 337 | XprLiteral< TP > \ |
sv | 1:6799c07fe510 | 338 | > expr_type; \ |
sv | 1:6799c07fe510 | 339 | return XprMatrix<expr_type, Rows, Cols>( \ |
sv | 1:6799c07fe510 | 340 | expr_type(lhs.const_ref(), XprLiteral< TP >(rhs))); \ |
sv | 1:6799c07fe510 | 341 | } |
sv | 1:6799c07fe510 | 342 | |
sv | 1:6799c07fe510 | 343 | TVMET_IMPLEMENT_MACRO(atan2, int) |
sv | 1:6799c07fe510 | 344 | TVMET_IMPLEMENT_MACRO(drem, int) |
sv | 1:6799c07fe510 | 345 | TVMET_IMPLEMENT_MACRO(fmod, int) |
sv | 1:6799c07fe510 | 346 | TVMET_IMPLEMENT_MACRO(hypot, int) |
sv | 1:6799c07fe510 | 347 | TVMET_IMPLEMENT_MACRO(jn, int) |
sv | 1:6799c07fe510 | 348 | TVMET_IMPLEMENT_MACRO(yn, int) |
sv | 1:6799c07fe510 | 349 | TVMET_IMPLEMENT_MACRO(pow, int) |
sv | 1:6799c07fe510 | 350 | |
sv | 1:6799c07fe510 | 351 | #if defined(TVMET_HAVE_LONG_LONG) |
sv | 1:6799c07fe510 | 352 | TVMET_IMPLEMENT_MACRO(atan2, long long int) |
sv | 1:6799c07fe510 | 353 | TVMET_IMPLEMENT_MACRO(drem, long long int) |
sv | 1:6799c07fe510 | 354 | TVMET_IMPLEMENT_MACRO(fmod, long long int) |
sv | 1:6799c07fe510 | 355 | TVMET_IMPLEMENT_MACRO(hypot, long long int) |
sv | 1:6799c07fe510 | 356 | TVMET_IMPLEMENT_MACRO(jn, long long int) |
sv | 1:6799c07fe510 | 357 | TVMET_IMPLEMENT_MACRO(yn, long long int) |
sv | 1:6799c07fe510 | 358 | TVMET_IMPLEMENT_MACRO(pow, long long int) |
sv | 1:6799c07fe510 | 359 | #endif // defined(TVMET_HAVE_LONG_LONG) |
sv | 1:6799c07fe510 | 360 | |
sv | 1:6799c07fe510 | 361 | TVMET_IMPLEMENT_MACRO(atan2, float) |
sv | 1:6799c07fe510 | 362 | TVMET_IMPLEMENT_MACRO(drem, float) |
sv | 1:6799c07fe510 | 363 | TVMET_IMPLEMENT_MACRO(fmod, float) |
sv | 1:6799c07fe510 | 364 | TVMET_IMPLEMENT_MACRO(hypot, float) |
sv | 1:6799c07fe510 | 365 | TVMET_IMPLEMENT_MACRO(jn, float) |
sv | 1:6799c07fe510 | 366 | TVMET_IMPLEMENT_MACRO(yn, float) |
sv | 1:6799c07fe510 | 367 | TVMET_IMPLEMENT_MACRO(pow, float) |
sv | 1:6799c07fe510 | 368 | |
sv | 1:6799c07fe510 | 369 | TVMET_IMPLEMENT_MACRO(atan2, double) |
sv | 1:6799c07fe510 | 370 | TVMET_IMPLEMENT_MACRO(drem, double) |
sv | 1:6799c07fe510 | 371 | TVMET_IMPLEMENT_MACRO(fmod, double) |
sv | 1:6799c07fe510 | 372 | TVMET_IMPLEMENT_MACRO(hypot, double) |
sv | 1:6799c07fe510 | 373 | TVMET_IMPLEMENT_MACRO(jn, double) |
sv | 1:6799c07fe510 | 374 | TVMET_IMPLEMENT_MACRO(yn, double) |
sv | 1:6799c07fe510 | 375 | TVMET_IMPLEMENT_MACRO(pow, double) |
sv | 1:6799c07fe510 | 376 | |
sv | 1:6799c07fe510 | 377 | #if defined(TVMET_HAVE_LONG_DOUBLE) |
sv | 1:6799c07fe510 | 378 | TVMET_IMPLEMENT_MACRO(atan2, long double) |
sv | 1:6799c07fe510 | 379 | TVMET_IMPLEMENT_MACRO(drem, long double) |
sv | 1:6799c07fe510 | 380 | TVMET_IMPLEMENT_MACRO(fmod, long double) |
sv | 1:6799c07fe510 | 381 | TVMET_IMPLEMENT_MACRO(hypot, long double) |
sv | 1:6799c07fe510 | 382 | TVMET_IMPLEMENT_MACRO(jn, long double) |
sv | 1:6799c07fe510 | 383 | TVMET_IMPLEMENT_MACRO(yn, long double) |
sv | 1:6799c07fe510 | 384 | TVMET_IMPLEMENT_MACRO(pow, long double) |
sv | 1:6799c07fe510 | 385 | #endif // defined(TVMET_HAVE_LONG_DOUBLE) |
sv | 1:6799c07fe510 | 386 | |
sv | 1:6799c07fe510 | 387 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 388 | |
sv | 1:6799c07fe510 | 389 | |
sv | 1:6799c07fe510 | 390 | /* |
sv | 1:6799c07fe510 | 391 | * complex math |
sv | 1:6799c07fe510 | 392 | */ |
sv | 1:6799c07fe510 | 393 | |
sv | 1:6799c07fe510 | 394 | #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1) |
sv | 1:6799c07fe510 | 395 | /** |
sv | 1:6799c07fe510 | 396 | * \fn pow(const Matrix<T, Rows, Cols>& lhs, const std::complex<T>& rhs) |
sv | 1:6799c07fe510 | 397 | * \ingroup _binary_function |
sv | 1:6799c07fe510 | 398 | */ |
sv | 1:6799c07fe510 | 399 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 400 | inline |
sv | 1:6799c07fe510 | 401 | XprMatrix< |
sv | 1:6799c07fe510 | 402 | XprBinOp< |
sv | 1:6799c07fe510 | 403 | Fcnl_pow<T, std::complex<T> >, |
sv | 1:6799c07fe510 | 404 | MatrixConstReference<T, Rows, Cols>, |
sv | 1:6799c07fe510 | 405 | XprLiteral< std::complex<T> > |
sv | 1:6799c07fe510 | 406 | >, |
sv | 1:6799c07fe510 | 407 | Rows, Cols |
sv | 1:6799c07fe510 | 408 | > |
sv | 1:6799c07fe510 | 409 | pow(const Matrix<T, Rows, Cols>& lhs, const std::complex<T>& rhs) { |
sv | 1:6799c07fe510 | 410 | typedef XprBinOp< |
sv | 1:6799c07fe510 | 411 | Fcnl_pow<T, std::complex<T> >, |
sv | 1:6799c07fe510 | 412 | MatrixConstReference<T, Rows, Cols>, |
sv | 1:6799c07fe510 | 413 | XprLiteral< std::complex<T> > |
sv | 1:6799c07fe510 | 414 | > expr_type; |
sv | 1:6799c07fe510 | 415 | return XprMatrix<expr_type, Rows, Cols>( |
sv | 1:6799c07fe510 | 416 | expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs))); |
sv | 1:6799c07fe510 | 417 | } |
sv | 1:6799c07fe510 | 418 | |
sv | 1:6799c07fe510 | 419 | |
sv | 1:6799c07fe510 | 420 | /** |
sv | 1:6799c07fe510 | 421 | * \fn pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const std::complex<T>& rhs) |
sv | 1:6799c07fe510 | 422 | * \ingroup _binary_function |
sv | 1:6799c07fe510 | 423 | */ |
sv | 1:6799c07fe510 | 424 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 425 | inline |
sv | 1:6799c07fe510 | 426 | XprMatrix< |
sv | 1:6799c07fe510 | 427 | XprBinOp< |
sv | 1:6799c07fe510 | 428 | Fcnl_pow< std::complex<T>, std::complex<T> >, |
sv | 1:6799c07fe510 | 429 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 430 | XprLiteral< std::complex<T> > |
sv | 1:6799c07fe510 | 431 | >, |
sv | 1:6799c07fe510 | 432 | Rows, Cols |
sv | 1:6799c07fe510 | 433 | > |
sv | 1:6799c07fe510 | 434 | pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const std::complex<T>& rhs) { |
sv | 1:6799c07fe510 | 435 | typedef XprBinOp< |
sv | 1:6799c07fe510 | 436 | Fcnl_pow< std::complex<T>, std::complex<T> >, |
sv | 1:6799c07fe510 | 437 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 438 | XprLiteral< std::complex<T> > |
sv | 1:6799c07fe510 | 439 | > expr_type; |
sv | 1:6799c07fe510 | 440 | return XprMatrix<expr_type, Rows, Cols>( |
sv | 1:6799c07fe510 | 441 | expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs))); |
sv | 1:6799c07fe510 | 442 | } |
sv | 1:6799c07fe510 | 443 | |
sv | 1:6799c07fe510 | 444 | |
sv | 1:6799c07fe510 | 445 | /** |
sv | 1:6799c07fe510 | 446 | * \fn pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const T& rhs) |
sv | 1:6799c07fe510 | 447 | * \ingroup _binary_function |
sv | 1:6799c07fe510 | 448 | */ |
sv | 1:6799c07fe510 | 449 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 450 | inline |
sv | 1:6799c07fe510 | 451 | XprMatrix< |
sv | 1:6799c07fe510 | 452 | XprBinOp< |
sv | 1:6799c07fe510 | 453 | Fcnl_pow<std::complex<T>, T>, |
sv | 1:6799c07fe510 | 454 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 455 | XprLiteral<T> |
sv | 1:6799c07fe510 | 456 | >, |
sv | 1:6799c07fe510 | 457 | Rows, Cols |
sv | 1:6799c07fe510 | 458 | > |
sv | 1:6799c07fe510 | 459 | pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const T& rhs) { |
sv | 1:6799c07fe510 | 460 | typedef XprBinOp< |
sv | 1:6799c07fe510 | 461 | Fcnl_pow<std::complex<T>, T>, |
sv | 1:6799c07fe510 | 462 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 463 | XprLiteral<T> |
sv | 1:6799c07fe510 | 464 | > expr_type; |
sv | 1:6799c07fe510 | 465 | return XprMatrix<expr_type, Rows, Cols>( |
sv | 1:6799c07fe510 | 466 | expr_type(lhs.const_ref(), XprLiteral<T>(rhs))); |
sv | 1:6799c07fe510 | 467 | } |
sv | 1:6799c07fe510 | 468 | |
sv | 1:6799c07fe510 | 469 | |
sv | 1:6799c07fe510 | 470 | /** |
sv | 1:6799c07fe510 | 471 | * \fn pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, int rhs) |
sv | 1:6799c07fe510 | 472 | * \ingroup _binary_function |
sv | 1:6799c07fe510 | 473 | */ |
sv | 1:6799c07fe510 | 474 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 475 | inline |
sv | 1:6799c07fe510 | 476 | XprMatrix< |
sv | 1:6799c07fe510 | 477 | XprBinOp< |
sv | 1:6799c07fe510 | 478 | Fcnl_pow<std::complex<T>, int>, |
sv | 1:6799c07fe510 | 479 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 480 | XprLiteral<int> |
sv | 1:6799c07fe510 | 481 | >, |
sv | 1:6799c07fe510 | 482 | Rows, Cols |
sv | 1:6799c07fe510 | 483 | > |
sv | 1:6799c07fe510 | 484 | pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, int rhs) { |
sv | 1:6799c07fe510 | 485 | typedef XprBinOp< |
sv | 1:6799c07fe510 | 486 | Fcnl_pow<std::complex<T>, int>, |
sv | 1:6799c07fe510 | 487 | MatrixConstReference<std::complex<T>, Rows, Cols>, |
sv | 1:6799c07fe510 | 488 | XprLiteral<int> |
sv | 1:6799c07fe510 | 489 | > expr_type; |
sv | 1:6799c07fe510 | 490 | return XprMatrix<expr_type, Rows, Cols>( |
sv | 1:6799c07fe510 | 491 | expr_type(lhs.const_ref(), XprLiteral<int>(rhs))); |
sv | 1:6799c07fe510 | 492 | } |
sv | 1:6799c07fe510 | 493 | |
sv | 1:6799c07fe510 | 494 | |
sv | 1:6799c07fe510 | 495 | /** |
sv | 1:6799c07fe510 | 496 | * \fn polar(const Matrix<T, Rows, Cols>& lhs, const T& rhs) |
sv | 1:6799c07fe510 | 497 | * \ingroup _binary_function |
sv | 1:6799c07fe510 | 498 | */ |
sv | 1:6799c07fe510 | 499 | template<class T, std::size_t Rows, std::size_t Cols> |
sv | 1:6799c07fe510 | 500 | inline |
sv | 1:6799c07fe510 | 501 | XprMatrix< |
sv | 1:6799c07fe510 | 502 | XprBinOp< |
sv | 1:6799c07fe510 | 503 | Fcnl_polar<T, T>, |
sv | 1:6799c07fe510 | 504 | MatrixConstReference<T, Rows, Cols>, |
sv | 1:6799c07fe510 | 505 | XprLiteral<T> |
sv | 1:6799c07fe510 | 506 | >, |
sv | 1:6799c07fe510 | 507 | Rows, Cols |
sv | 1:6799c07fe510 | 508 | > |
sv | 1:6799c07fe510 | 509 | polar(const Matrix<T, Rows, Cols>& lhs, const T& rhs) { |
sv | 1:6799c07fe510 | 510 | typedef XprBinOp< |
sv | 1:6799c07fe510 | 511 | Fcnl_polar<T, T>, |
sv | 1:6799c07fe510 | 512 | MatrixConstReference<T, Rows, Cols>, |
sv | 1:6799c07fe510 | 513 | XprLiteral<T> |
sv | 1:6799c07fe510 | 514 | > expr_type; |
sv | 1:6799c07fe510 | 515 | return XprMatrix<expr_type, Rows, Cols>( |
sv | 1:6799c07fe510 | 516 | expr_type(lhs.const_ref(), XprLiteral<T>(rhs))); |
sv | 1:6799c07fe510 | 517 | } |
sv | 1:6799c07fe510 | 518 | |
sv | 1:6799c07fe510 | 519 | #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1) |
sv | 1:6799c07fe510 | 520 | |
sv | 1:6799c07fe510 | 521 | #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2) |
sv | 1:6799c07fe510 | 522 | // to be written (atan2) |
sv | 1:6799c07fe510 | 523 | #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2) |
sv | 1:6799c07fe510 | 524 | |
sv | 1:6799c07fe510 | 525 | |
sv | 1:6799c07fe510 | 526 | } // namespace tvmet |
sv | 1:6799c07fe510 | 527 | |
sv | 1:6799c07fe510 | 528 | #endif // TVMET_MATRIX_BINARY_FUNCTIONS_H |
sv | 1:6799c07fe510 | 529 | |
sv | 1:6799c07fe510 | 530 | // Local Variables: |
sv | 1:6799c07fe510 | 531 | // mode:C++ |
sv | 1:6799c07fe510 | 532 | // tab-width:8 |
sv | 1:6799c07fe510 | 533 | // End: |