Colour sensors calibrated

Dependencies:   mbed-rtos mbed Servo QEI

Fork of ICRSEurobot13 by Thomas Branch

Committer:
xiaxia686
Date:
Fri Apr 12 20:59:18 2013 +0000
Revision:
46:adcd57a5e402
Parent:
15:9c5aaeda36dc
Colours Sensors fixed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 15:9c5aaeda36dc 1 /*
madcowswe 15:9c5aaeda36dc 2 * Tiny Vector Matrix Library
madcowswe 15:9c5aaeda36dc 3 * Dense Vector Matrix Libary of Tiny size using Expression Templates
madcowswe 15:9c5aaeda36dc 4 *
madcowswe 15:9c5aaeda36dc 5 * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
madcowswe 15:9c5aaeda36dc 6 *
madcowswe 15:9c5aaeda36dc 7 * This library is free software; you can redistribute it and/or
madcowswe 15:9c5aaeda36dc 8 * modify it under the terms of the GNU lesser General Public
madcowswe 15:9c5aaeda36dc 9 * License as published by the Free Software Foundation; either
madcowswe 15:9c5aaeda36dc 10 * version 2.1 of the License, or (at your option) any later version.
madcowswe 15:9c5aaeda36dc 11 *
madcowswe 15:9c5aaeda36dc 12 * This library is distributed in the hope that it will be useful,
madcowswe 15:9c5aaeda36dc 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
madcowswe 15:9c5aaeda36dc 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
madcowswe 15:9c5aaeda36dc 15 * lesser General Public License for more details.
madcowswe 15:9c5aaeda36dc 16 *
madcowswe 15:9c5aaeda36dc 17 * You should have received a copy of the GNU lesser General Public
madcowswe 15:9c5aaeda36dc 18 * License along with this library; if not, write to the Free Software
madcowswe 15:9c5aaeda36dc 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
madcowswe 15:9c5aaeda36dc 20 *
madcowswe 15:9c5aaeda36dc 21 * $Id: MatrixOperators.h,v 1.37 2007-06-23 15:58:58 opetzold Exp $
madcowswe 15:9c5aaeda36dc 22 */
madcowswe 15:9c5aaeda36dc 23
madcowswe 15:9c5aaeda36dc 24 #ifndef TVMET_MATRIX_OPERATORS_H
madcowswe 15:9c5aaeda36dc 25 #define TVMET_MATRIX_OPERATORS_H
madcowswe 15:9c5aaeda36dc 26
madcowswe 15:9c5aaeda36dc 27 namespace tvmet {
madcowswe 15:9c5aaeda36dc 28
madcowswe 15:9c5aaeda36dc 29
madcowswe 15:9c5aaeda36dc 30 /*********************************************************
madcowswe 15:9c5aaeda36dc 31 * PART I: DECLARATION
madcowswe 15:9c5aaeda36dc 32 *********************************************************/
madcowswe 15:9c5aaeda36dc 33
madcowswe 15:9c5aaeda36dc 34
madcowswe 15:9c5aaeda36dc 35 template<class T, std::size_t Rows, std::size_t Cols>
madcowswe 15:9c5aaeda36dc 36 std::ostream& operator<<(std::ostream& os,
madcowswe 15:9c5aaeda36dc 37 const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 38
madcowswe 15:9c5aaeda36dc 39
madcowswe 15:9c5aaeda36dc 40 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 41 * Member operators (arithmetic and bit ops)
madcowswe 15:9c5aaeda36dc 42 *++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 43
madcowswe 15:9c5aaeda36dc 44
madcowswe 15:9c5aaeda36dc 45 /*
madcowswe 15:9c5aaeda36dc 46 * update_operator(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 47 * update_operator(Matrix<T1, Rows, Cols>, XprMatrix<E, Rows, Cols> rhs)
madcowswe 15:9c5aaeda36dc 48 * Note: per se element wise
madcowswe 15:9c5aaeda36dc 49 * \todo: the operator*= can have element wise mul oder product, decide!
madcowswe 15:9c5aaeda36dc 50 */
madcowswe 15:9c5aaeda36dc 51 #define TVMET_DECLARE_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 52 template<class T1, class T2, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 53 Matrix<T1, Rows, Cols>& \
madcowswe 15:9c5aaeda36dc 54 operator OP (Matrix<T1, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 55 const Matrix<T2, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 56 \
madcowswe 15:9c5aaeda36dc 57 template<class T, class E, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 58 Matrix<T, Rows, Cols>& \
madcowswe 15:9c5aaeda36dc 59 operator OP (Matrix<T, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 60 const XprMatrix<E, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 61
madcowswe 15:9c5aaeda36dc 62 TVMET_DECLARE_MACRO(add_eq, +=) // per se element wise
madcowswe 15:9c5aaeda36dc 63 TVMET_DECLARE_MACRO(sub_eq, -=) // per se element wise
madcowswe 15:9c5aaeda36dc 64 namespace element_wise {
madcowswe 15:9c5aaeda36dc 65 TVMET_DECLARE_MACRO(mul_eq, *=) // see note
madcowswe 15:9c5aaeda36dc 66 TVMET_DECLARE_MACRO(div_eq, /=) // not defined for vectors
madcowswe 15:9c5aaeda36dc 67 }
madcowswe 15:9c5aaeda36dc 68
madcowswe 15:9c5aaeda36dc 69 // integer operators only, e.g used on double you wil get an error
madcowswe 15:9c5aaeda36dc 70 namespace element_wise {
madcowswe 15:9c5aaeda36dc 71 TVMET_DECLARE_MACRO(mod_eq, %=)
madcowswe 15:9c5aaeda36dc 72 TVMET_DECLARE_MACRO(xor_eq, ^=)
madcowswe 15:9c5aaeda36dc 73 TVMET_DECLARE_MACRO(and_eq, &=)
madcowswe 15:9c5aaeda36dc 74 TVMET_DECLARE_MACRO(or_eq, |=)
madcowswe 15:9c5aaeda36dc 75 TVMET_DECLARE_MACRO(shl_eq, <<=)
madcowswe 15:9c5aaeda36dc 76 TVMET_DECLARE_MACRO(shr_eq, >>=)
madcowswe 15:9c5aaeda36dc 77 }
madcowswe 15:9c5aaeda36dc 78
madcowswe 15:9c5aaeda36dc 79 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 80
madcowswe 15:9c5aaeda36dc 81
madcowswe 15:9c5aaeda36dc 82 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 83 * Matrix arithmetic operators implemented by functions
madcowswe 15:9c5aaeda36dc 84 * add, sub, mul and div
madcowswe 15:9c5aaeda36dc 85 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 86
madcowswe 15:9c5aaeda36dc 87
madcowswe 15:9c5aaeda36dc 88 /*
madcowswe 15:9c5aaeda36dc 89 * operator(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 90 * operator(XprMatrix<E, Rows, Cols>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 91 * operator(Matrix<T, Rows, Cols>, XprMatrix<E, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 92 * Note: per se element wise
madcowswe 15:9c5aaeda36dc 93 */
madcowswe 15:9c5aaeda36dc 94 #define TVMET_DECLARE_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 95 template<class T1, class T2, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 96 XprMatrix< \
madcowswe 15:9c5aaeda36dc 97 XprBinOp< \
madcowswe 15:9c5aaeda36dc 98 Fcnl_##NAME<T1, T2>, \
madcowswe 15:9c5aaeda36dc 99 MatrixConstReference<T1, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 100 MatrixConstReference<T2, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 101 >, \
madcowswe 15:9c5aaeda36dc 102 Rows, Cols \
madcowswe 15:9c5aaeda36dc 103 > \
madcowswe 15:9c5aaeda36dc 104 operator OP (const Matrix<T1, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 105 const Matrix<T2, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 106 \
madcowswe 15:9c5aaeda36dc 107 template<class E, class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 108 XprMatrix< \
madcowswe 15:9c5aaeda36dc 109 XprBinOp< \
madcowswe 15:9c5aaeda36dc 110 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 111 XprMatrix<E, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 112 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 113 >, \
madcowswe 15:9c5aaeda36dc 114 Rows, Cols \
madcowswe 15:9c5aaeda36dc 115 > \
madcowswe 15:9c5aaeda36dc 116 operator OP (const XprMatrix<E, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 117 const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 118 \
madcowswe 15:9c5aaeda36dc 119 template<class T, class E, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 120 XprMatrix< \
madcowswe 15:9c5aaeda36dc 121 XprBinOp< \
madcowswe 15:9c5aaeda36dc 122 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 123 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 124 XprMatrix<E, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 125 >, \
madcowswe 15:9c5aaeda36dc 126 Rows, Cols \
madcowswe 15:9c5aaeda36dc 127 > \
madcowswe 15:9c5aaeda36dc 128 operator OP (const Matrix<T, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 129 const XprMatrix<E, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 130
madcowswe 15:9c5aaeda36dc 131 TVMET_DECLARE_MACRO(add, +) // per se element wise
madcowswe 15:9c5aaeda36dc 132 TVMET_DECLARE_MACRO(sub, -) // per se element wise
madcowswe 15:9c5aaeda36dc 133 namespace element_wise {
madcowswe 15:9c5aaeda36dc 134 TVMET_DECLARE_MACRO(mul, *) // see as prod()
madcowswe 15:9c5aaeda36dc 135 TVMET_DECLARE_MACRO(div, /) // not defined for matrizes
madcowswe 15:9c5aaeda36dc 136 }
madcowswe 15:9c5aaeda36dc 137 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 138
madcowswe 15:9c5aaeda36dc 139
madcowswe 15:9c5aaeda36dc 140 /*
madcowswe 15:9c5aaeda36dc 141 * operator(Matrix<T, Rows, Cols>, POD)
madcowswe 15:9c5aaeda36dc 142 * operator(POD, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 143 * Note: operations +,-,*,/ are per se element wise
madcowswe 15:9c5aaeda36dc 144 */
madcowswe 15:9c5aaeda36dc 145 #define TVMET_DECLARE_MACRO(NAME, OP, POD) \
madcowswe 15:9c5aaeda36dc 146 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 147 XprMatrix< \
madcowswe 15:9c5aaeda36dc 148 XprBinOp< \
madcowswe 15:9c5aaeda36dc 149 Fcnl_##NAME<T, POD >, \
madcowswe 15:9c5aaeda36dc 150 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 151 XprLiteral<POD > \
madcowswe 15:9c5aaeda36dc 152 >, \
madcowswe 15:9c5aaeda36dc 153 Rows, Cols \
madcowswe 15:9c5aaeda36dc 154 > \
madcowswe 15:9c5aaeda36dc 155 operator OP (const Matrix<T, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 156 POD rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 157 \
madcowswe 15:9c5aaeda36dc 158 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 159 XprMatrix< \
madcowswe 15:9c5aaeda36dc 160 XprBinOp< \
madcowswe 15:9c5aaeda36dc 161 Fcnl_##NAME< POD, T>, \
madcowswe 15:9c5aaeda36dc 162 XprLiteral< POD >, \
madcowswe 15:9c5aaeda36dc 163 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 164 >, \
madcowswe 15:9c5aaeda36dc 165 Rows, Cols \
madcowswe 15:9c5aaeda36dc 166 > \
madcowswe 15:9c5aaeda36dc 167 operator OP (POD lhs, \
madcowswe 15:9c5aaeda36dc 168 const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 169
madcowswe 15:9c5aaeda36dc 170 TVMET_DECLARE_MACRO(add, +, int)
madcowswe 15:9c5aaeda36dc 171 TVMET_DECLARE_MACRO(sub, -, int)
madcowswe 15:9c5aaeda36dc 172 TVMET_DECLARE_MACRO(mul, *, int)
madcowswe 15:9c5aaeda36dc 173 TVMET_DECLARE_MACRO(div, /, int)
madcowswe 15:9c5aaeda36dc 174
madcowswe 15:9c5aaeda36dc 175 #if defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 176 TVMET_DECLARE_MACRO(add, +, long long int)
madcowswe 15:9c5aaeda36dc 177 TVMET_DECLARE_MACRO(sub, -, long long int)
madcowswe 15:9c5aaeda36dc 178 TVMET_DECLARE_MACRO(mul, *, long long int)
madcowswe 15:9c5aaeda36dc 179 TVMET_DECLARE_MACRO(div, /, long long int)
madcowswe 15:9c5aaeda36dc 180 #endif // defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 181
madcowswe 15:9c5aaeda36dc 182 TVMET_DECLARE_MACRO(add, +, float)
madcowswe 15:9c5aaeda36dc 183 TVMET_DECLARE_MACRO(sub, -, float)
madcowswe 15:9c5aaeda36dc 184 TVMET_DECLARE_MACRO(mul, *, float)
madcowswe 15:9c5aaeda36dc 185 TVMET_DECLARE_MACRO(div, /, float)
madcowswe 15:9c5aaeda36dc 186
madcowswe 15:9c5aaeda36dc 187 TVMET_DECLARE_MACRO(add, +, double)
madcowswe 15:9c5aaeda36dc 188 TVMET_DECLARE_MACRO(sub, -, double)
madcowswe 15:9c5aaeda36dc 189 TVMET_DECLARE_MACRO(mul, *, double)
madcowswe 15:9c5aaeda36dc 190 TVMET_DECLARE_MACRO(div, /, double)
madcowswe 15:9c5aaeda36dc 191
madcowswe 15:9c5aaeda36dc 192 #if defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 193 TVMET_DECLARE_MACRO(add, +, long double)
madcowswe 15:9c5aaeda36dc 194 TVMET_DECLARE_MACRO(sub, -, long double)
madcowswe 15:9c5aaeda36dc 195 TVMET_DECLARE_MACRO(mul, *, long double)
madcowswe 15:9c5aaeda36dc 196 TVMET_DECLARE_MACRO(div, /, long double)
madcowswe 15:9c5aaeda36dc 197 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 198
madcowswe 15:9c5aaeda36dc 199 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 200
madcowswe 15:9c5aaeda36dc 201
madcowswe 15:9c5aaeda36dc 202 #if defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 203 /*
madcowswe 15:9c5aaeda36dc 204 * operator(Matrix<T, Rows, Cols>, complex<T>)
madcowswe 15:9c5aaeda36dc 205 * operator(complex<T>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 206 * Note: operations +,-,*,/ are per se element wise
madcowswe 15:9c5aaeda36dc 207 * \todo type promotion
madcowswe 15:9c5aaeda36dc 208 */
madcowswe 15:9c5aaeda36dc 209 #define TVMET_DECLARE_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 210 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 211 XprMatrix< \
madcowswe 15:9c5aaeda36dc 212 XprBinOp< \
madcowswe 15:9c5aaeda36dc 213 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 214 MatrixConstReference< std::complex<T>, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 215 XprLiteral<std::complex<T> > \
madcowswe 15:9c5aaeda36dc 216 >, \
madcowswe 15:9c5aaeda36dc 217 Rows, Cols \
madcowswe 15:9c5aaeda36dc 218 > \
madcowswe 15:9c5aaeda36dc 219 operator OP (const Matrix< std::complex<T>, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 220 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 221 \
madcowswe 15:9c5aaeda36dc 222 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 223 XprMatrix< \
madcowswe 15:9c5aaeda36dc 224 XprBinOp< \
madcowswe 15:9c5aaeda36dc 225 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 226 XprLiteral< std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 227 MatrixConstReference< std::complex<T>, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 228 >, \
madcowswe 15:9c5aaeda36dc 229 Rows, Cols \
madcowswe 15:9c5aaeda36dc 230 > \
madcowswe 15:9c5aaeda36dc 231 operator OP (const std::complex<T>& lhs, \
madcowswe 15:9c5aaeda36dc 232 const Matrix< std::complex<T>, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 233
madcowswe 15:9c5aaeda36dc 234 TVMET_DECLARE_MACRO(add, +)
madcowswe 15:9c5aaeda36dc 235 TVMET_DECLARE_MACRO(sub, -)
madcowswe 15:9c5aaeda36dc 236 TVMET_DECLARE_MACRO(mul, *)
madcowswe 15:9c5aaeda36dc 237 TVMET_DECLARE_MACRO(div, /)
madcowswe 15:9c5aaeda36dc 238
madcowswe 15:9c5aaeda36dc 239 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 240
madcowswe 15:9c5aaeda36dc 241 #endif // defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 242
madcowswe 15:9c5aaeda36dc 243
madcowswe 15:9c5aaeda36dc 244 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 245 * matrix specific operator*() = prod() operations
madcowswe 15:9c5aaeda36dc 246 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 247
madcowswe 15:9c5aaeda36dc 248
madcowswe 15:9c5aaeda36dc 249 template<class T1, std::size_t Rows1, std::size_t Cols1,
madcowswe 15:9c5aaeda36dc 250 class T2, std::size_t Cols2>
madcowswe 15:9c5aaeda36dc 251 XprMatrix<
madcowswe 15:9c5aaeda36dc 252 XprMMProduct<
madcowswe 15:9c5aaeda36dc 253 MatrixConstReference<T1, Rows1, Cols1>, Rows1, Cols1,
madcowswe 15:9c5aaeda36dc 254 MatrixConstReference<T2, Cols1, Cols2>, Cols2
madcowswe 15:9c5aaeda36dc 255 >,
madcowswe 15:9c5aaeda36dc 256 Rows1, Cols2
madcowswe 15:9c5aaeda36dc 257 >
madcowswe 15:9c5aaeda36dc 258 operator*(const Matrix<T1, Rows1, Cols1>& lhs,
madcowswe 15:9c5aaeda36dc 259 const Matrix<T2, Cols1, Cols2>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 260
madcowswe 15:9c5aaeda36dc 261
madcowswe 15:9c5aaeda36dc 262 template<class E1, std::size_t Rows1, std::size_t Cols1,
madcowswe 15:9c5aaeda36dc 263 class T2, std::size_t Cols2>
madcowswe 15:9c5aaeda36dc 264 XprMatrix<
madcowswe 15:9c5aaeda36dc 265 XprMMProduct<
madcowswe 15:9c5aaeda36dc 266 XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1,
madcowswe 15:9c5aaeda36dc 267 MatrixConstReference<T2, Cols1, Cols2>, Cols2
madcowswe 15:9c5aaeda36dc 268 >,
madcowswe 15:9c5aaeda36dc 269 Rows1, Cols2
madcowswe 15:9c5aaeda36dc 270 >
madcowswe 15:9c5aaeda36dc 271 operator*(const XprMatrix<E1, Rows1, Cols1>& lhs,
madcowswe 15:9c5aaeda36dc 272 const Matrix<T2, Cols1, Cols2>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 273
madcowswe 15:9c5aaeda36dc 274
madcowswe 15:9c5aaeda36dc 275 template<class T1, std::size_t Rows1, std::size_t Cols1,
madcowswe 15:9c5aaeda36dc 276 class E2, std::size_t Cols2>
madcowswe 15:9c5aaeda36dc 277 XprMatrix<
madcowswe 15:9c5aaeda36dc 278 XprMMProduct<
madcowswe 15:9c5aaeda36dc 279 MatrixConstReference<T1, Rows1, Cols1>, Rows1, Cols1,
madcowswe 15:9c5aaeda36dc 280 XprMatrix<E2, Cols1, Cols2>, Cols2
madcowswe 15:9c5aaeda36dc 281 >,
madcowswe 15:9c5aaeda36dc 282 Rows1, Cols2
madcowswe 15:9c5aaeda36dc 283 >
madcowswe 15:9c5aaeda36dc 284 operator*(const Matrix<T1, Rows1, Cols1>& lhs,
madcowswe 15:9c5aaeda36dc 285 const XprMatrix<E2, Cols1, Cols2>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 286
madcowswe 15:9c5aaeda36dc 287
madcowswe 15:9c5aaeda36dc 288 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 289 * matrix-vector specific prod( ... ) operators
madcowswe 15:9c5aaeda36dc 290 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 291
madcowswe 15:9c5aaeda36dc 292
madcowswe 15:9c5aaeda36dc 293 template<class T1, std::size_t Rows, std::size_t Cols, class T2>
madcowswe 15:9c5aaeda36dc 294 XprVector<
madcowswe 15:9c5aaeda36dc 295 XprMVProduct<
madcowswe 15:9c5aaeda36dc 296 MatrixConstReference<T1, Rows, Cols>, Rows, Cols,
madcowswe 15:9c5aaeda36dc 297 VectorConstReference<T2, Cols>
madcowswe 15:9c5aaeda36dc 298 >,
madcowswe 15:9c5aaeda36dc 299 Rows
madcowswe 15:9c5aaeda36dc 300 >
madcowswe 15:9c5aaeda36dc 301 operator*(const Matrix<T1, Rows, Cols>& lhs,
madcowswe 15:9c5aaeda36dc 302 const Vector<T2, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 303
madcowswe 15:9c5aaeda36dc 304
madcowswe 15:9c5aaeda36dc 305 template<class T1, class E2, std::size_t Rows, std::size_t Cols>
madcowswe 15:9c5aaeda36dc 306 XprVector<
madcowswe 15:9c5aaeda36dc 307 XprMVProduct<
madcowswe 15:9c5aaeda36dc 308 MatrixConstReference<T1, Rows, Cols>, Rows, Cols,
madcowswe 15:9c5aaeda36dc 309 XprVector<E2, Cols>
madcowswe 15:9c5aaeda36dc 310 >,
madcowswe 15:9c5aaeda36dc 311 Rows
madcowswe 15:9c5aaeda36dc 312 >
madcowswe 15:9c5aaeda36dc 313 operator*(const Matrix<T1, Rows, Cols>& lhs,
madcowswe 15:9c5aaeda36dc 314 const XprVector<E2, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 315
madcowswe 15:9c5aaeda36dc 316
madcowswe 15:9c5aaeda36dc 317 template<class E1, class T2, std::size_t Rows, std::size_t Cols>
madcowswe 15:9c5aaeda36dc 318 XprVector<
madcowswe 15:9c5aaeda36dc 319 XprMVProduct<
madcowswe 15:9c5aaeda36dc 320 XprMatrix<E1, Rows, Cols>, Rows, Cols,
madcowswe 15:9c5aaeda36dc 321 VectorConstReference<T2, Cols>
madcowswe 15:9c5aaeda36dc 322 >,
madcowswe 15:9c5aaeda36dc 323 Rows
madcowswe 15:9c5aaeda36dc 324 >
madcowswe 15:9c5aaeda36dc 325 operator*(const XprMatrix<E1, Rows, Cols>& lhs,
madcowswe 15:9c5aaeda36dc 326 const Vector<T2, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 327
madcowswe 15:9c5aaeda36dc 328
madcowswe 15:9c5aaeda36dc 329 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 330 * Matrix integer and compare operators
madcowswe 15:9c5aaeda36dc 331 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 332
madcowswe 15:9c5aaeda36dc 333
madcowswe 15:9c5aaeda36dc 334 /*
madcowswe 15:9c5aaeda36dc 335 * operator(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 336 * operator(XprMatrix<E>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 337 * operator(Matrix<T, Rows, Cols>, XprMatrix<E>)
madcowswe 15:9c5aaeda36dc 338 * Note: operations are per se element wise
madcowswe 15:9c5aaeda36dc 339 */
madcowswe 15:9c5aaeda36dc 340 #define TVMET_DECLARE_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 341 template<class T1, std::size_t Rows, std::size_t Cols, \
madcowswe 15:9c5aaeda36dc 342 class T2> \
madcowswe 15:9c5aaeda36dc 343 XprMatrix< \
madcowswe 15:9c5aaeda36dc 344 XprBinOp< \
madcowswe 15:9c5aaeda36dc 345 Fcnl_##NAME<T1, T2>, \
madcowswe 15:9c5aaeda36dc 346 MatrixConstReference<T1, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 347 MatrixConstReference<T2, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 348 >, \
madcowswe 15:9c5aaeda36dc 349 Rows, Cols \
madcowswe 15:9c5aaeda36dc 350 > \
madcowswe 15:9c5aaeda36dc 351 operator OP (const Matrix<T1, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 352 const Matrix<T2, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 353 \
madcowswe 15:9c5aaeda36dc 354 template<class E, \
madcowswe 15:9c5aaeda36dc 355 class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 356 XprMatrix< \
madcowswe 15:9c5aaeda36dc 357 XprBinOp< \
madcowswe 15:9c5aaeda36dc 358 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 359 XprMatrix<E, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 360 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 361 >, \
madcowswe 15:9c5aaeda36dc 362 Rows, Cols \
madcowswe 15:9c5aaeda36dc 363 > \
madcowswe 15:9c5aaeda36dc 364 operator OP (const XprMatrix<E, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 365 const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 366 \
madcowswe 15:9c5aaeda36dc 367 template<class T, std::size_t Rows, std::size_t Cols, \
madcowswe 15:9c5aaeda36dc 368 class E> \
madcowswe 15:9c5aaeda36dc 369 XprMatrix< \
madcowswe 15:9c5aaeda36dc 370 XprBinOp< \
madcowswe 15:9c5aaeda36dc 371 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 372 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 373 XprMatrix<E, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 374 >, \
madcowswe 15:9c5aaeda36dc 375 Rows, Cols \
madcowswe 15:9c5aaeda36dc 376 > \
madcowswe 15:9c5aaeda36dc 377 operator OP (const Matrix<T, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 378 const XprMatrix<E, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 379
madcowswe 15:9c5aaeda36dc 380 // integer operators only, e.g used on double you wil get an error
madcowswe 15:9c5aaeda36dc 381 namespace element_wise {
madcowswe 15:9c5aaeda36dc 382 TVMET_DECLARE_MACRO(mod, %)
madcowswe 15:9c5aaeda36dc 383 TVMET_DECLARE_MACRO(bitxor, ^)
madcowswe 15:9c5aaeda36dc 384 TVMET_DECLARE_MACRO(bitand, &)
madcowswe 15:9c5aaeda36dc 385 TVMET_DECLARE_MACRO(bitor, |)
madcowswe 15:9c5aaeda36dc 386 TVMET_DECLARE_MACRO(shl, <<)
madcowswe 15:9c5aaeda36dc 387 TVMET_DECLARE_MACRO(shr, >>)
madcowswe 15:9c5aaeda36dc 388 }
madcowswe 15:9c5aaeda36dc 389
madcowswe 15:9c5aaeda36dc 390 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 391 TVMET_DECLARE_MACRO(greater, >)
madcowswe 15:9c5aaeda36dc 392 TVMET_DECLARE_MACRO(less, <)
madcowswe 15:9c5aaeda36dc 393 TVMET_DECLARE_MACRO(greater_eq, >=)
madcowswe 15:9c5aaeda36dc 394 TVMET_DECLARE_MACRO(less_eq, <=)
madcowswe 15:9c5aaeda36dc 395 TVMET_DECLARE_MACRO(eq, ==)
madcowswe 15:9c5aaeda36dc 396 TVMET_DECLARE_MACRO(not_eq, !=)
madcowswe 15:9c5aaeda36dc 397 TVMET_DECLARE_MACRO(and, &&)
madcowswe 15:9c5aaeda36dc 398 TVMET_DECLARE_MACRO(or, ||)
madcowswe 15:9c5aaeda36dc 399
madcowswe 15:9c5aaeda36dc 400 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 401
madcowswe 15:9c5aaeda36dc 402
madcowswe 15:9c5aaeda36dc 403 #if defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 404 /*
madcowswe 15:9c5aaeda36dc 405 * operator(Matrix<T, Rows, Cols>, complex<T>)
madcowswe 15:9c5aaeda36dc 406 * operator(complex<T>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 407 * Note: - per se element wise
madcowswe 15:9c5aaeda36dc 408 * - bit ops on complex<int> doesn't make sense, stay away
madcowswe 15:9c5aaeda36dc 409 * \todo type promotion
madcowswe 15:9c5aaeda36dc 410 */
madcowswe 15:9c5aaeda36dc 411 #define TVMET_DECLARE_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 412 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 413 XprMatrix< \
madcowswe 15:9c5aaeda36dc 414 XprBinOp< \
madcowswe 15:9c5aaeda36dc 415 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 416 MatrixConstReference< std::complex<T>, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 417 XprLiteral<std::complex<T> > \
madcowswe 15:9c5aaeda36dc 418 >, \
madcowswe 15:9c5aaeda36dc 419 Rows, Cols \
madcowswe 15:9c5aaeda36dc 420 > \
madcowswe 15:9c5aaeda36dc 421 operator OP (const Matrix< std::complex<T>, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 422 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 423 \
madcowswe 15:9c5aaeda36dc 424 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 425 XprMatrix< \
madcowswe 15:9c5aaeda36dc 426 XprBinOp< \
madcowswe 15:9c5aaeda36dc 427 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 428 XprLiteral< std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 429 MatrixConstReference< std::complex<T>, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 430 >, \
madcowswe 15:9c5aaeda36dc 431 Rows, Cols \
madcowswe 15:9c5aaeda36dc 432 > \
madcowswe 15:9c5aaeda36dc 433 operator OP (const std::complex<T>& lhs, \
madcowswe 15:9c5aaeda36dc 434 const Matrix< std::complex<T>, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 435
madcowswe 15:9c5aaeda36dc 436 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 437 TVMET_DECLARE_MACRO(greater, >)
madcowswe 15:9c5aaeda36dc 438 TVMET_DECLARE_MACRO(less, <)
madcowswe 15:9c5aaeda36dc 439 TVMET_DECLARE_MACRO(greater_eq, >=)
madcowswe 15:9c5aaeda36dc 440 TVMET_DECLARE_MACRO(less_eq, <=)
madcowswe 15:9c5aaeda36dc 441 TVMET_DECLARE_MACRO(eq, ==)
madcowswe 15:9c5aaeda36dc 442 TVMET_DECLARE_MACRO(not_eq, !=)
madcowswe 15:9c5aaeda36dc 443 TVMET_DECLARE_MACRO(and, &&)
madcowswe 15:9c5aaeda36dc 444 TVMET_DECLARE_MACRO(or, ||)
madcowswe 15:9c5aaeda36dc 445
madcowswe 15:9c5aaeda36dc 446 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 447
madcowswe 15:9c5aaeda36dc 448 #endif // defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 449
madcowswe 15:9c5aaeda36dc 450
madcowswe 15:9c5aaeda36dc 451 /*
madcowswe 15:9c5aaeda36dc 452 * operator(Matrix<T, Rows, Cols>, POD)
madcowswe 15:9c5aaeda36dc 453 * operator(POD, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 454 * Note: operations are per se element wise
madcowswe 15:9c5aaeda36dc 455 */
madcowswe 15:9c5aaeda36dc 456 #define TVMET_DECLARE_MACRO(NAME, OP, TP) \
madcowswe 15:9c5aaeda36dc 457 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 458 XprMatrix< \
madcowswe 15:9c5aaeda36dc 459 XprBinOp< \
madcowswe 15:9c5aaeda36dc 460 Fcnl_##NAME<T, TP >, \
madcowswe 15:9c5aaeda36dc 461 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 462 XprLiteral<TP > \
madcowswe 15:9c5aaeda36dc 463 >, \
madcowswe 15:9c5aaeda36dc 464 Rows, Cols \
madcowswe 15:9c5aaeda36dc 465 > \
madcowswe 15:9c5aaeda36dc 466 operator OP (const Matrix<T, Rows, Cols>& lhs, TP rhs) TVMET_CXX_ALWAYS_INLINE; \
madcowswe 15:9c5aaeda36dc 467 \
madcowswe 15:9c5aaeda36dc 468 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 469 XprMatrix< \
madcowswe 15:9c5aaeda36dc 470 XprBinOp< \
madcowswe 15:9c5aaeda36dc 471 Fcnl_##NAME< TP, T>, \
madcowswe 15:9c5aaeda36dc 472 XprLiteral< TP >, \
madcowswe 15:9c5aaeda36dc 473 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 474 >, \
madcowswe 15:9c5aaeda36dc 475 Rows, Cols \
madcowswe 15:9c5aaeda36dc 476 > \
madcowswe 15:9c5aaeda36dc 477 operator OP (TP lhs, const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 478
madcowswe 15:9c5aaeda36dc 479 // integer operators only, e.g used on double you wil get an error
madcowswe 15:9c5aaeda36dc 480 namespace element_wise {
madcowswe 15:9c5aaeda36dc 481 TVMET_DECLARE_MACRO(mod, %, int)
madcowswe 15:9c5aaeda36dc 482 TVMET_DECLARE_MACRO(bitxor, ^, int)
madcowswe 15:9c5aaeda36dc 483 TVMET_DECLARE_MACRO(bitand, &, int)
madcowswe 15:9c5aaeda36dc 484 TVMET_DECLARE_MACRO(bitor, |, int)
madcowswe 15:9c5aaeda36dc 485 TVMET_DECLARE_MACRO(shl, <<, int)
madcowswe 15:9c5aaeda36dc 486 TVMET_DECLARE_MACRO(shr, >>, int)
madcowswe 15:9c5aaeda36dc 487 }
madcowswe 15:9c5aaeda36dc 488
madcowswe 15:9c5aaeda36dc 489 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 490 TVMET_DECLARE_MACRO(greater, >, int)
madcowswe 15:9c5aaeda36dc 491 TVMET_DECLARE_MACRO(less, <, int)
madcowswe 15:9c5aaeda36dc 492 TVMET_DECLARE_MACRO(greater_eq, >=, int)
madcowswe 15:9c5aaeda36dc 493 TVMET_DECLARE_MACRO(less_eq, <=, int)
madcowswe 15:9c5aaeda36dc 494 TVMET_DECLARE_MACRO(eq, ==, int)
madcowswe 15:9c5aaeda36dc 495 TVMET_DECLARE_MACRO(not_eq, !=, int)
madcowswe 15:9c5aaeda36dc 496 TVMET_DECLARE_MACRO(and, &&, int)
madcowswe 15:9c5aaeda36dc 497 TVMET_DECLARE_MACRO(or, ||, int)
madcowswe 15:9c5aaeda36dc 498
madcowswe 15:9c5aaeda36dc 499 #if defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 500 // integer operators only
madcowswe 15:9c5aaeda36dc 501 namespace element_wise {
madcowswe 15:9c5aaeda36dc 502 TVMET_DECLARE_MACRO(mod, %, long long int)
madcowswe 15:9c5aaeda36dc 503 TVMET_DECLARE_MACRO(bitxor, ^, long long int)
madcowswe 15:9c5aaeda36dc 504 TVMET_DECLARE_MACRO(bitand, &, long long int)
madcowswe 15:9c5aaeda36dc 505 TVMET_DECLARE_MACRO(bitor, |, long long int)
madcowswe 15:9c5aaeda36dc 506 TVMET_DECLARE_MACRO(shl, <<, long long int)
madcowswe 15:9c5aaeda36dc 507 TVMET_DECLARE_MACRO(shr, >>, long long int)
madcowswe 15:9c5aaeda36dc 508 }
madcowswe 15:9c5aaeda36dc 509
madcowswe 15:9c5aaeda36dc 510 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 511 TVMET_DECLARE_MACRO(greater, >, long long int)
madcowswe 15:9c5aaeda36dc 512 TVMET_DECLARE_MACRO(less, <, long long int)
madcowswe 15:9c5aaeda36dc 513 TVMET_DECLARE_MACRO(greater_eq, >=, long long int)
madcowswe 15:9c5aaeda36dc 514 TVMET_DECLARE_MACRO(less_eq, <=, long long int)
madcowswe 15:9c5aaeda36dc 515 TVMET_DECLARE_MACRO(eq, ==, long long int)
madcowswe 15:9c5aaeda36dc 516 TVMET_DECLARE_MACRO(not_eq, !=, long long int)
madcowswe 15:9c5aaeda36dc 517 TVMET_DECLARE_MACRO(and, &&, long long int)
madcowswe 15:9c5aaeda36dc 518 TVMET_DECLARE_MACRO(or, ||, long long int)
madcowswe 15:9c5aaeda36dc 519 #endif // defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 520
madcowswe 15:9c5aaeda36dc 521 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 522 TVMET_DECLARE_MACRO(greater, >, float)
madcowswe 15:9c5aaeda36dc 523 TVMET_DECLARE_MACRO(less, <, float)
madcowswe 15:9c5aaeda36dc 524 TVMET_DECLARE_MACRO(greater_eq, >=, float)
madcowswe 15:9c5aaeda36dc 525 TVMET_DECLARE_MACRO(less_eq, <=, float)
madcowswe 15:9c5aaeda36dc 526 TVMET_DECLARE_MACRO(eq, ==, float)
madcowswe 15:9c5aaeda36dc 527 TVMET_DECLARE_MACRO(not_eq, !=, float)
madcowswe 15:9c5aaeda36dc 528 TVMET_DECLARE_MACRO(and, &&, float)
madcowswe 15:9c5aaeda36dc 529 TVMET_DECLARE_MACRO(or, ||, float)
madcowswe 15:9c5aaeda36dc 530
madcowswe 15:9c5aaeda36dc 531 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 532 TVMET_DECLARE_MACRO(greater, >, double)
madcowswe 15:9c5aaeda36dc 533 TVMET_DECLARE_MACRO(less, <, double)
madcowswe 15:9c5aaeda36dc 534 TVMET_DECLARE_MACRO(greater_eq, >=, double)
madcowswe 15:9c5aaeda36dc 535 TVMET_DECLARE_MACRO(less_eq, <=, double)
madcowswe 15:9c5aaeda36dc 536 TVMET_DECLARE_MACRO(eq, ==, double)
madcowswe 15:9c5aaeda36dc 537 TVMET_DECLARE_MACRO(not_eq, !=, double)
madcowswe 15:9c5aaeda36dc 538 TVMET_DECLARE_MACRO(and, &&, double)
madcowswe 15:9c5aaeda36dc 539 TVMET_DECLARE_MACRO(or, ||, double)
madcowswe 15:9c5aaeda36dc 540
madcowswe 15:9c5aaeda36dc 541 #if defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 542 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 543 TVMET_DECLARE_MACRO(greater, >, long double)
madcowswe 15:9c5aaeda36dc 544 TVMET_DECLARE_MACRO(less, <, long double)
madcowswe 15:9c5aaeda36dc 545 TVMET_DECLARE_MACRO(greater_eq, >=, long double)
madcowswe 15:9c5aaeda36dc 546 TVMET_DECLARE_MACRO(less_eq, <=, long double)
madcowswe 15:9c5aaeda36dc 547 TVMET_DECLARE_MACRO(eq, ==, long double)
madcowswe 15:9c5aaeda36dc 548 TVMET_DECLARE_MACRO(not_eq, !=, long double)
madcowswe 15:9c5aaeda36dc 549 TVMET_DECLARE_MACRO(and, &&, long double)
madcowswe 15:9c5aaeda36dc 550 TVMET_DECLARE_MACRO(or, ||, long double)
madcowswe 15:9c5aaeda36dc 551 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 552
madcowswe 15:9c5aaeda36dc 553 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 554
madcowswe 15:9c5aaeda36dc 555
madcowswe 15:9c5aaeda36dc 556
madcowswe 15:9c5aaeda36dc 557
madcowswe 15:9c5aaeda36dc 558 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 559 * global unary operators
madcowswe 15:9c5aaeda36dc 560 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 561
madcowswe 15:9c5aaeda36dc 562
madcowswe 15:9c5aaeda36dc 563 /*
madcowswe 15:9c5aaeda36dc 564 * unary_operator(Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 565 * Note: per se element wise
madcowswe 15:9c5aaeda36dc 566 */
madcowswe 15:9c5aaeda36dc 567 #define TVMET_DECLARE_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 568 template <class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 569 XprMatrix< \
madcowswe 15:9c5aaeda36dc 570 XprUnOp< \
madcowswe 15:9c5aaeda36dc 571 Fcnl_##NAME<T>, \
madcowswe 15:9c5aaeda36dc 572 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 573 >, \
madcowswe 15:9c5aaeda36dc 574 Rows, Cols \
madcowswe 15:9c5aaeda36dc 575 > \
madcowswe 15:9c5aaeda36dc 576 operator OP (const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
madcowswe 15:9c5aaeda36dc 577
madcowswe 15:9c5aaeda36dc 578 TVMET_DECLARE_MACRO(not, !)
madcowswe 15:9c5aaeda36dc 579 TVMET_DECLARE_MACRO(compl, ~)
madcowswe 15:9c5aaeda36dc 580 TVMET_DECLARE_MACRO(neg, -)
madcowswe 15:9c5aaeda36dc 581 #undef TVMET_DECLARE_MACRO
madcowswe 15:9c5aaeda36dc 582
madcowswe 15:9c5aaeda36dc 583
madcowswe 15:9c5aaeda36dc 584 /*********************************************************
madcowswe 15:9c5aaeda36dc 585 * PART II: IMPLEMENTATION
madcowswe 15:9c5aaeda36dc 586 *********************************************************/
madcowswe 15:9c5aaeda36dc 587
madcowswe 15:9c5aaeda36dc 588
madcowswe 15:9c5aaeda36dc 589 /**
madcowswe 15:9c5aaeda36dc 590 * \fn operator<<(std::ostream& os, const Matrix<T, Rows, Cols>& rhs)
madcowswe 15:9c5aaeda36dc 591 * \brief Overload operator for i/o
madcowswe 15:9c5aaeda36dc 592 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 593 */
madcowswe 15:9c5aaeda36dc 594 template<class T, std::size_t Rows, std::size_t Cols>
madcowswe 15:9c5aaeda36dc 595 inline
madcowswe 15:9c5aaeda36dc 596 std::ostream& operator<<(std::ostream& os, const Matrix<T, Rows, Cols>& rhs) {
madcowswe 15:9c5aaeda36dc 597 return rhs.print_on(os);
madcowswe 15:9c5aaeda36dc 598 }
madcowswe 15:9c5aaeda36dc 599
madcowswe 15:9c5aaeda36dc 600
madcowswe 15:9c5aaeda36dc 601 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 602 * Member operators (arithmetic and bit ops)
madcowswe 15:9c5aaeda36dc 603 *++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 604
madcowswe 15:9c5aaeda36dc 605
madcowswe 15:9c5aaeda36dc 606 /*
madcowswe 15:9c5aaeda36dc 607 * update_operator(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 608 * update_operator(Matrix<T1, Rows, Cols>, XprMatrix<E, Rows, Cols> rhs)
madcowswe 15:9c5aaeda36dc 609 * Note: per se element wise
madcowswe 15:9c5aaeda36dc 610 * \todo: the operator*= can have element wise mul oder product, decide!
madcowswe 15:9c5aaeda36dc 611 */
madcowswe 15:9c5aaeda36dc 612 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 613 template<class T1, class T2, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 614 inline \
madcowswe 15:9c5aaeda36dc 615 Matrix<T1, Rows, Cols>& \
madcowswe 15:9c5aaeda36dc 616 operator OP (Matrix<T1, Rows, Cols>& lhs, const Matrix<T2, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 617 return lhs.M_##NAME(rhs); \
madcowswe 15:9c5aaeda36dc 618 } \
madcowswe 15:9c5aaeda36dc 619 \
madcowswe 15:9c5aaeda36dc 620 template<class T, class E, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 621 inline \
madcowswe 15:9c5aaeda36dc 622 Matrix<T, Rows, Cols>& \
madcowswe 15:9c5aaeda36dc 623 operator OP (Matrix<T, Rows, Cols>& lhs, const XprMatrix<E, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 624 return lhs.M_##NAME(rhs); \
madcowswe 15:9c5aaeda36dc 625 }
madcowswe 15:9c5aaeda36dc 626
madcowswe 15:9c5aaeda36dc 627 TVMET_IMPLEMENT_MACRO(add_eq, +=) // per se element wise
madcowswe 15:9c5aaeda36dc 628 TVMET_IMPLEMENT_MACRO(sub_eq, -=) // per se element wise
madcowswe 15:9c5aaeda36dc 629 namespace element_wise {
madcowswe 15:9c5aaeda36dc 630 TVMET_IMPLEMENT_MACRO(mul_eq, *=) // see note
madcowswe 15:9c5aaeda36dc 631 TVMET_IMPLEMENT_MACRO(div_eq, /=) // not defined for vectors
madcowswe 15:9c5aaeda36dc 632 }
madcowswe 15:9c5aaeda36dc 633
madcowswe 15:9c5aaeda36dc 634 // integer operators only, e.g used on double you wil get an error
madcowswe 15:9c5aaeda36dc 635 namespace element_wise {
madcowswe 15:9c5aaeda36dc 636 TVMET_IMPLEMENT_MACRO(mod_eq, %=)
madcowswe 15:9c5aaeda36dc 637 TVMET_IMPLEMENT_MACRO(xor_eq, ^=)
madcowswe 15:9c5aaeda36dc 638 TVMET_IMPLEMENT_MACRO(and_eq, &=)
madcowswe 15:9c5aaeda36dc 639 TVMET_IMPLEMENT_MACRO(or_eq, |=)
madcowswe 15:9c5aaeda36dc 640 TVMET_IMPLEMENT_MACRO(shl_eq, <<=)
madcowswe 15:9c5aaeda36dc 641 TVMET_IMPLEMENT_MACRO(shr_eq, >>=)
madcowswe 15:9c5aaeda36dc 642 }
madcowswe 15:9c5aaeda36dc 643
madcowswe 15:9c5aaeda36dc 644 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 645
madcowswe 15:9c5aaeda36dc 646
madcowswe 15:9c5aaeda36dc 647 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 648 * Matrix arithmetic operators implemented by functions
madcowswe 15:9c5aaeda36dc 649 * add, sub, mul and div
madcowswe 15:9c5aaeda36dc 650 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 651
madcowswe 15:9c5aaeda36dc 652
madcowswe 15:9c5aaeda36dc 653 /*
madcowswe 15:9c5aaeda36dc 654 * operator(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 655 * operator(XprMatrix<E, Rows, Cols>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 656 * operator(Matrix<T, Rows, Cols>, XprMatrix<E, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 657 * Note: per se element wise
madcowswe 15:9c5aaeda36dc 658 */
madcowswe 15:9c5aaeda36dc 659 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 660 template<class T1, class T2, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 661 inline \
madcowswe 15:9c5aaeda36dc 662 XprMatrix< \
madcowswe 15:9c5aaeda36dc 663 XprBinOp< \
madcowswe 15:9c5aaeda36dc 664 Fcnl_##NAME<T1, T2>, \
madcowswe 15:9c5aaeda36dc 665 MatrixConstReference<T1, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 666 MatrixConstReference<T2, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 667 >, \
madcowswe 15:9c5aaeda36dc 668 Rows, Cols \
madcowswe 15:9c5aaeda36dc 669 > \
madcowswe 15:9c5aaeda36dc 670 operator OP (const Matrix<T1, Rows, Cols>& lhs, const Matrix<T2, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 671 return NAME(lhs, rhs); \
madcowswe 15:9c5aaeda36dc 672 } \
madcowswe 15:9c5aaeda36dc 673 \
madcowswe 15:9c5aaeda36dc 674 template<class E, class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 675 inline \
madcowswe 15:9c5aaeda36dc 676 XprMatrix< \
madcowswe 15:9c5aaeda36dc 677 XprBinOp< \
madcowswe 15:9c5aaeda36dc 678 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 679 XprMatrix<E, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 680 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 681 >, \
madcowswe 15:9c5aaeda36dc 682 Rows, Cols \
madcowswe 15:9c5aaeda36dc 683 > \
madcowswe 15:9c5aaeda36dc 684 operator OP (const XprMatrix<E, Rows, Cols>& lhs, const Matrix<T, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 685 return NAME(lhs, rhs); \
madcowswe 15:9c5aaeda36dc 686 } \
madcowswe 15:9c5aaeda36dc 687 \
madcowswe 15:9c5aaeda36dc 688 template<class T, class E, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 689 inline \
madcowswe 15:9c5aaeda36dc 690 XprMatrix< \
madcowswe 15:9c5aaeda36dc 691 XprBinOp< \
madcowswe 15:9c5aaeda36dc 692 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 693 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 694 XprMatrix<E, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 695 >, \
madcowswe 15:9c5aaeda36dc 696 Rows, Cols \
madcowswe 15:9c5aaeda36dc 697 > \
madcowswe 15:9c5aaeda36dc 698 operator OP (const Matrix<T, Rows, Cols>& lhs, const XprMatrix<E, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 699 return NAME(lhs, rhs); \
madcowswe 15:9c5aaeda36dc 700 }
madcowswe 15:9c5aaeda36dc 701
madcowswe 15:9c5aaeda36dc 702 TVMET_IMPLEMENT_MACRO(add, +) // per se element wise
madcowswe 15:9c5aaeda36dc 703 TVMET_IMPLEMENT_MACRO(sub, -) // per se element wise
madcowswe 15:9c5aaeda36dc 704 namespace element_wise {
madcowswe 15:9c5aaeda36dc 705 TVMET_IMPLEMENT_MACRO(mul, *) // see as prod()
madcowswe 15:9c5aaeda36dc 706 TVMET_IMPLEMENT_MACRO(div, /) // not defined for matrizes
madcowswe 15:9c5aaeda36dc 707 }
madcowswe 15:9c5aaeda36dc 708 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 709
madcowswe 15:9c5aaeda36dc 710
madcowswe 15:9c5aaeda36dc 711 /*
madcowswe 15:9c5aaeda36dc 712 * operator(Matrix<T, Rows, Cols>, POD)
madcowswe 15:9c5aaeda36dc 713 * operator(POD, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 714 * Note: operations +,-,*,/ are per se element wise
madcowswe 15:9c5aaeda36dc 715 */
madcowswe 15:9c5aaeda36dc 716 #define TVMET_IMPLEMENT_MACRO(NAME, OP, POD) \
madcowswe 15:9c5aaeda36dc 717 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 718 inline \
madcowswe 15:9c5aaeda36dc 719 XprMatrix< \
madcowswe 15:9c5aaeda36dc 720 XprBinOp< \
madcowswe 15:9c5aaeda36dc 721 Fcnl_##NAME<T, POD >, \
madcowswe 15:9c5aaeda36dc 722 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 723 XprLiteral<POD > \
madcowswe 15:9c5aaeda36dc 724 >, \
madcowswe 15:9c5aaeda36dc 725 Rows, Cols \
madcowswe 15:9c5aaeda36dc 726 > \
madcowswe 15:9c5aaeda36dc 727 operator OP (const Matrix<T, Rows, Cols>& lhs, POD rhs) { \
madcowswe 15:9c5aaeda36dc 728 return NAME (lhs, rhs); \
madcowswe 15:9c5aaeda36dc 729 } \
madcowswe 15:9c5aaeda36dc 730 \
madcowswe 15:9c5aaeda36dc 731 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 732 inline \
madcowswe 15:9c5aaeda36dc 733 XprMatrix< \
madcowswe 15:9c5aaeda36dc 734 XprBinOp< \
madcowswe 15:9c5aaeda36dc 735 Fcnl_##NAME< POD, T>, \
madcowswe 15:9c5aaeda36dc 736 XprLiteral< POD >, \
madcowswe 15:9c5aaeda36dc 737 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 738 >, \
madcowswe 15:9c5aaeda36dc 739 Rows, Cols \
madcowswe 15:9c5aaeda36dc 740 > \
madcowswe 15:9c5aaeda36dc 741 operator OP (POD lhs, const Matrix<T, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 742 return NAME (lhs, rhs); \
madcowswe 15:9c5aaeda36dc 743 }
madcowswe 15:9c5aaeda36dc 744
madcowswe 15:9c5aaeda36dc 745 TVMET_IMPLEMENT_MACRO(add, +, int)
madcowswe 15:9c5aaeda36dc 746 TVMET_IMPLEMENT_MACRO(sub, -, int)
madcowswe 15:9c5aaeda36dc 747 TVMET_IMPLEMENT_MACRO(mul, *, int)
madcowswe 15:9c5aaeda36dc 748 TVMET_IMPLEMENT_MACRO(div, /, int)
madcowswe 15:9c5aaeda36dc 749
madcowswe 15:9c5aaeda36dc 750 #if defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 751 TVMET_IMPLEMENT_MACRO(add, +, long long int)
madcowswe 15:9c5aaeda36dc 752 TVMET_IMPLEMENT_MACRO(sub, -, long long int)
madcowswe 15:9c5aaeda36dc 753 TVMET_IMPLEMENT_MACRO(mul, *, long long int)
madcowswe 15:9c5aaeda36dc 754 TVMET_IMPLEMENT_MACRO(div, /, long long int)
madcowswe 15:9c5aaeda36dc 755 #endif // defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 756
madcowswe 15:9c5aaeda36dc 757 TVMET_IMPLEMENT_MACRO(add, +, float)
madcowswe 15:9c5aaeda36dc 758 TVMET_IMPLEMENT_MACRO(sub, -, float)
madcowswe 15:9c5aaeda36dc 759 TVMET_IMPLEMENT_MACRO(mul, *, float)
madcowswe 15:9c5aaeda36dc 760 TVMET_IMPLEMENT_MACRO(div, /, float)
madcowswe 15:9c5aaeda36dc 761
madcowswe 15:9c5aaeda36dc 762 TVMET_IMPLEMENT_MACRO(add, +, double)
madcowswe 15:9c5aaeda36dc 763 TVMET_IMPLEMENT_MACRO(sub, -, double)
madcowswe 15:9c5aaeda36dc 764 TVMET_IMPLEMENT_MACRO(mul, *, double)
madcowswe 15:9c5aaeda36dc 765 TVMET_IMPLEMENT_MACRO(div, /, double)
madcowswe 15:9c5aaeda36dc 766
madcowswe 15:9c5aaeda36dc 767 #if defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 768 TVMET_IMPLEMENT_MACRO(add, +, long double)
madcowswe 15:9c5aaeda36dc 769 TVMET_IMPLEMENT_MACRO(sub, -, long double)
madcowswe 15:9c5aaeda36dc 770 TVMET_IMPLEMENT_MACRO(mul, *, long double)
madcowswe 15:9c5aaeda36dc 771 TVMET_IMPLEMENT_MACRO(div, /, long double)
madcowswe 15:9c5aaeda36dc 772 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 773
madcowswe 15:9c5aaeda36dc 774 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 775
madcowswe 15:9c5aaeda36dc 776
madcowswe 15:9c5aaeda36dc 777 #if defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 778 /*
madcowswe 15:9c5aaeda36dc 779 * operator(Matrix<T, Rows, Cols>, complex<T>)
madcowswe 15:9c5aaeda36dc 780 * operator(complex<T>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 781 * Note: operations +,-,*,/ are per se element wise
madcowswe 15:9c5aaeda36dc 782 * \todo type promotion
madcowswe 15:9c5aaeda36dc 783 */
madcowswe 15:9c5aaeda36dc 784 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 785 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 786 inline \
madcowswe 15:9c5aaeda36dc 787 XprMatrix< \
madcowswe 15:9c5aaeda36dc 788 XprBinOp< \
madcowswe 15:9c5aaeda36dc 789 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 790 MatrixConstReference< std::complex<T>, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 791 XprLiteral<std::complex<T> > \
madcowswe 15:9c5aaeda36dc 792 >, \
madcowswe 15:9c5aaeda36dc 793 Rows, Cols \
madcowswe 15:9c5aaeda36dc 794 > \
madcowswe 15:9c5aaeda36dc 795 operator OP (const Matrix< std::complex<T>, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 796 const std::complex<T>& rhs) { \
madcowswe 15:9c5aaeda36dc 797 return NAME (lhs, rhs); \
madcowswe 15:9c5aaeda36dc 798 } \
madcowswe 15:9c5aaeda36dc 799 \
madcowswe 15:9c5aaeda36dc 800 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 801 inline \
madcowswe 15:9c5aaeda36dc 802 XprMatrix< \
madcowswe 15:9c5aaeda36dc 803 XprBinOp< \
madcowswe 15:9c5aaeda36dc 804 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 805 XprLiteral< std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 806 MatrixConstReference< std::complex<T>, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 807 >, \
madcowswe 15:9c5aaeda36dc 808 Rows, Cols \
madcowswe 15:9c5aaeda36dc 809 > \
madcowswe 15:9c5aaeda36dc 810 operator OP (const std::complex<T>& lhs, \
madcowswe 15:9c5aaeda36dc 811 const Matrix< std::complex<T>, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 812 return NAME (lhs, rhs); \
madcowswe 15:9c5aaeda36dc 813 }
madcowswe 15:9c5aaeda36dc 814
madcowswe 15:9c5aaeda36dc 815 TVMET_IMPLEMENT_MACRO(add, +)
madcowswe 15:9c5aaeda36dc 816 TVMET_IMPLEMENT_MACRO(sub, -)
madcowswe 15:9c5aaeda36dc 817 TVMET_IMPLEMENT_MACRO(mul, *)
madcowswe 15:9c5aaeda36dc 818 TVMET_IMPLEMENT_MACRO(div, /)
madcowswe 15:9c5aaeda36dc 819
madcowswe 15:9c5aaeda36dc 820 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 821
madcowswe 15:9c5aaeda36dc 822 #endif // defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 823
madcowswe 15:9c5aaeda36dc 824
madcowswe 15:9c5aaeda36dc 825 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 826 * matrix specific operator*() = prod() operations
madcowswe 15:9c5aaeda36dc 827 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 828
madcowswe 15:9c5aaeda36dc 829
madcowswe 15:9c5aaeda36dc 830 /**
madcowswe 15:9c5aaeda36dc 831 * \fn operator*(const Matrix<T1, Rows1, Cols1>& lhs, const Matrix<T2, Cols1, Cols2>& rhs)
madcowswe 15:9c5aaeda36dc 832 * \brief multiply two Matrices.
madcowswe 15:9c5aaeda36dc 833 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 834 * \note The rows2 has to be equal to cols1.
madcowswe 15:9c5aaeda36dc 835 * \sa prod(const Matrix<T1, Rows1, Cols1>& lhs, const Matrix<T2, Cols1, Cols2>& rhs)
madcowswe 15:9c5aaeda36dc 836 */
madcowswe 15:9c5aaeda36dc 837 template<class T1, std::size_t Rows1, std::size_t Cols1,
madcowswe 15:9c5aaeda36dc 838 class T2, std::size_t Cols2>
madcowswe 15:9c5aaeda36dc 839 inline
madcowswe 15:9c5aaeda36dc 840 XprMatrix<
madcowswe 15:9c5aaeda36dc 841 XprMMProduct<
madcowswe 15:9c5aaeda36dc 842 MatrixConstReference<T1, Rows1, Cols1>, Rows1, Cols1,
madcowswe 15:9c5aaeda36dc 843 MatrixConstReference<T2, Cols1, Cols2>, Cols2
madcowswe 15:9c5aaeda36dc 844 >,
madcowswe 15:9c5aaeda36dc 845 Rows1, Cols2
madcowswe 15:9c5aaeda36dc 846 >
madcowswe 15:9c5aaeda36dc 847 operator*(const Matrix<T1, Rows1, Cols1>& lhs, const Matrix<T2, Cols1, Cols2>& rhs) {
madcowswe 15:9c5aaeda36dc 848 return prod(lhs, rhs);
madcowswe 15:9c5aaeda36dc 849 }
madcowswe 15:9c5aaeda36dc 850
madcowswe 15:9c5aaeda36dc 851
madcowswe 15:9c5aaeda36dc 852 /**
madcowswe 15:9c5aaeda36dc 853 * \fn operator*(const XprMatrix<E1, Rows1, Cols1>& lhs, const Matrix<T2, Cols1, Cols2>& rhs)
madcowswe 15:9c5aaeda36dc 854 * \brief Evaluate the product of XprMatrix and Matrix.
madcowswe 15:9c5aaeda36dc 855 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 856 * \sa prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const Matrix<T2, Cols1, Cols2>& rhs)
madcowswe 15:9c5aaeda36dc 857 */
madcowswe 15:9c5aaeda36dc 858 template<class E1, std::size_t Rows1, std::size_t Cols1,
madcowswe 15:9c5aaeda36dc 859 class T2, std::size_t Cols2>
madcowswe 15:9c5aaeda36dc 860 inline
madcowswe 15:9c5aaeda36dc 861 XprMatrix<
madcowswe 15:9c5aaeda36dc 862 XprMMProduct<
madcowswe 15:9c5aaeda36dc 863 XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1,
madcowswe 15:9c5aaeda36dc 864 MatrixConstReference<T2, Cols1, Cols2>, Cols2
madcowswe 15:9c5aaeda36dc 865 >,
madcowswe 15:9c5aaeda36dc 866 Rows1, Cols2
madcowswe 15:9c5aaeda36dc 867 >
madcowswe 15:9c5aaeda36dc 868 operator*(const XprMatrix<E1, Rows1, Cols1>& lhs, const Matrix<T2, Cols1, Cols2>& rhs) {
madcowswe 15:9c5aaeda36dc 869 return prod(lhs, rhs);
madcowswe 15:9c5aaeda36dc 870 }
madcowswe 15:9c5aaeda36dc 871
madcowswe 15:9c5aaeda36dc 872
madcowswe 15:9c5aaeda36dc 873 /**
madcowswe 15:9c5aaeda36dc 874 * \fn operator*(const Matrix<T1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs)
madcowswe 15:9c5aaeda36dc 875 * \brief Evaluate the product of Matrix and XprMatrix.
madcowswe 15:9c5aaeda36dc 876 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 877 * \sa prod(const Matrix<T, Rows1, Cols1>& lhs, const XprMatrix<E, Cols1, Cols2>& rhs)
madcowswe 15:9c5aaeda36dc 878 */
madcowswe 15:9c5aaeda36dc 879 template<class T1, std::size_t Rows1, std::size_t Cols1,
madcowswe 15:9c5aaeda36dc 880 class E2, std::size_t Cols2>
madcowswe 15:9c5aaeda36dc 881 inline
madcowswe 15:9c5aaeda36dc 882 XprMatrix<
madcowswe 15:9c5aaeda36dc 883 XprMMProduct<
madcowswe 15:9c5aaeda36dc 884 MatrixConstReference<T1, Rows1, Cols1>, Rows1, Cols1,
madcowswe 15:9c5aaeda36dc 885 XprMatrix<E2, Cols1, Cols2>, Cols2
madcowswe 15:9c5aaeda36dc 886 >,
madcowswe 15:9c5aaeda36dc 887 Rows1, Cols2
madcowswe 15:9c5aaeda36dc 888 >
madcowswe 15:9c5aaeda36dc 889 operator*(const Matrix<T1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) {
madcowswe 15:9c5aaeda36dc 890 return prod(lhs, rhs);
madcowswe 15:9c5aaeda36dc 891 }
madcowswe 15:9c5aaeda36dc 892
madcowswe 15:9c5aaeda36dc 893
madcowswe 15:9c5aaeda36dc 894 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 895 * matrix-vector specific prod( ... ) operators
madcowswe 15:9c5aaeda36dc 896 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 897
madcowswe 15:9c5aaeda36dc 898
madcowswe 15:9c5aaeda36dc 899 /**
madcowswe 15:9c5aaeda36dc 900 * \fn operator*(const Matrix<T1, Rows, Cols>& lhs, const Vector<T2, Cols>& rhs)
madcowswe 15:9c5aaeda36dc 901 * \brief multiply a Matrix with a Vector.
madcowswe 15:9c5aaeda36dc 902 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 903 * \note The length of the Vector has to be equal to the number of Columns.
madcowswe 15:9c5aaeda36dc 904 * \sa prod(const Matrix<T1, Rows, Cols>& m, const Vector<T2, Cols>& v)
madcowswe 15:9c5aaeda36dc 905 */
madcowswe 15:9c5aaeda36dc 906 template<class T1, std::size_t Rows, std::size_t Cols, class T2>
madcowswe 15:9c5aaeda36dc 907 inline
madcowswe 15:9c5aaeda36dc 908 XprVector<
madcowswe 15:9c5aaeda36dc 909 XprMVProduct<
madcowswe 15:9c5aaeda36dc 910 MatrixConstReference<T1, Rows, Cols>, Rows, Cols,
madcowswe 15:9c5aaeda36dc 911 VectorConstReference<T2, Cols>
madcowswe 15:9c5aaeda36dc 912 >,
madcowswe 15:9c5aaeda36dc 913 Rows
madcowswe 15:9c5aaeda36dc 914 >
madcowswe 15:9c5aaeda36dc 915 operator*(const Matrix<T1, Rows, Cols>& lhs, const Vector<T2, Cols>& rhs) {
madcowswe 15:9c5aaeda36dc 916 return prod(lhs, rhs);
madcowswe 15:9c5aaeda36dc 917 }
madcowswe 15:9c5aaeda36dc 918
madcowswe 15:9c5aaeda36dc 919
madcowswe 15:9c5aaeda36dc 920 /**
madcowswe 15:9c5aaeda36dc 921 * \fn operator*(const Matrix<T1, Rows, Cols>& lhs, const XprVector<E2, Cols>& rhs)
madcowswe 15:9c5aaeda36dc 922 * \brief Function for the matrix-vector-product
madcowswe 15:9c5aaeda36dc 923 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 924 * \sa prod(const Matrix<T, Rows, Cols>& lhs, const XprVector<E, Cols>& rhs)
madcowswe 15:9c5aaeda36dc 925 */
madcowswe 15:9c5aaeda36dc 926 template<class T1, class E2, std::size_t Rows, std::size_t Cols>
madcowswe 15:9c5aaeda36dc 927 inline
madcowswe 15:9c5aaeda36dc 928 XprVector<
madcowswe 15:9c5aaeda36dc 929 XprMVProduct<
madcowswe 15:9c5aaeda36dc 930 MatrixConstReference<T1, Rows, Cols>, Rows, Cols,
madcowswe 15:9c5aaeda36dc 931 XprVector<E2, Cols>
madcowswe 15:9c5aaeda36dc 932 >,
madcowswe 15:9c5aaeda36dc 933 Rows
madcowswe 15:9c5aaeda36dc 934 >
madcowswe 15:9c5aaeda36dc 935 operator*(const Matrix<T1, Rows, Cols>& lhs, const XprVector<E2, Cols>& rhs) {
madcowswe 15:9c5aaeda36dc 936 return prod(lhs, rhs);
madcowswe 15:9c5aaeda36dc 937 }
madcowswe 15:9c5aaeda36dc 938
madcowswe 15:9c5aaeda36dc 939
madcowswe 15:9c5aaeda36dc 940 /**
madcowswe 15:9c5aaeda36dc 941 * \fn operator*(const XprMatrix<E1, Rows, Cols>& lhs, const Vector<T2, Cols>& rhs)
madcowswe 15:9c5aaeda36dc 942 * \brief Compute the product of an XprMatrix with a Vector.
madcowswe 15:9c5aaeda36dc 943 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 944 * \sa prod(const XprMatrix<E, Rows, Cols>& lhs, const Vector<T, Cols>& rhs)
madcowswe 15:9c5aaeda36dc 945 */
madcowswe 15:9c5aaeda36dc 946 template<class E1, class T2, std::size_t Rows, std::size_t Cols>
madcowswe 15:9c5aaeda36dc 947 inline
madcowswe 15:9c5aaeda36dc 948 XprVector<
madcowswe 15:9c5aaeda36dc 949 XprMVProduct<
madcowswe 15:9c5aaeda36dc 950 XprMatrix<E1, Rows, Cols>, Rows, Cols,
madcowswe 15:9c5aaeda36dc 951 VectorConstReference<T2, Cols>
madcowswe 15:9c5aaeda36dc 952 >,
madcowswe 15:9c5aaeda36dc 953 Rows
madcowswe 15:9c5aaeda36dc 954 >
madcowswe 15:9c5aaeda36dc 955 operator*(const XprMatrix<E1, Rows, Cols>& lhs, const Vector<T2, Cols>& rhs) {
madcowswe 15:9c5aaeda36dc 956 return prod(lhs, rhs);
madcowswe 15:9c5aaeda36dc 957 }
madcowswe 15:9c5aaeda36dc 958
madcowswe 15:9c5aaeda36dc 959
madcowswe 15:9c5aaeda36dc 960 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 961 * Matrix integer and compare operators
madcowswe 15:9c5aaeda36dc 962 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 963
madcowswe 15:9c5aaeda36dc 964
madcowswe 15:9c5aaeda36dc 965 /*
madcowswe 15:9c5aaeda36dc 966 * operator(Matrix<T1, Rows, Cols>, Matrix<T2, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 967 * operator(XprMatrix<E>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 968 * operator(Matrix<T, Rows, Cols>, XprMatrix<E>)
madcowswe 15:9c5aaeda36dc 969 * Note: operations are per se element wise
madcowswe 15:9c5aaeda36dc 970 */
madcowswe 15:9c5aaeda36dc 971 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 972 template<class T1, std::size_t Rows, std::size_t Cols, \
madcowswe 15:9c5aaeda36dc 973 class T2> \
madcowswe 15:9c5aaeda36dc 974 inline \
madcowswe 15:9c5aaeda36dc 975 XprMatrix< \
madcowswe 15:9c5aaeda36dc 976 XprBinOp< \
madcowswe 15:9c5aaeda36dc 977 Fcnl_##NAME<T1, T2>, \
madcowswe 15:9c5aaeda36dc 978 MatrixConstReference<T1, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 979 MatrixConstReference<T2, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 980 >, \
madcowswe 15:9c5aaeda36dc 981 Rows, Cols \
madcowswe 15:9c5aaeda36dc 982 > \
madcowswe 15:9c5aaeda36dc 983 operator OP (const Matrix<T1, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 984 const Matrix<T2, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 985 typedef XprBinOp < \
madcowswe 15:9c5aaeda36dc 986 Fcnl_##NAME<T1, T2>, \
madcowswe 15:9c5aaeda36dc 987 MatrixConstReference<T1, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 988 MatrixConstReference<T2, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 989 > expr_type; \
madcowswe 15:9c5aaeda36dc 990 return XprMatrix<expr_type, Rows, Cols>(expr_type(lhs.const_ref(), rhs.const_ref())); \
madcowswe 15:9c5aaeda36dc 991 } \
madcowswe 15:9c5aaeda36dc 992 \
madcowswe 15:9c5aaeda36dc 993 template<class E, \
madcowswe 15:9c5aaeda36dc 994 class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 995 inline \
madcowswe 15:9c5aaeda36dc 996 XprMatrix< \
madcowswe 15:9c5aaeda36dc 997 XprBinOp< \
madcowswe 15:9c5aaeda36dc 998 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 999 XprMatrix<E, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1000 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1001 >, \
madcowswe 15:9c5aaeda36dc 1002 Rows, Cols \
madcowswe 15:9c5aaeda36dc 1003 > \
madcowswe 15:9c5aaeda36dc 1004 operator OP (const XprMatrix<E, Rows, Cols>& lhs, const Matrix<T, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 1005 typedef XprBinOp< \
madcowswe 15:9c5aaeda36dc 1006 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 1007 XprMatrix<E, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1008 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1009 > expr_type; \
madcowswe 15:9c5aaeda36dc 1010 return XprMatrix<expr_type, Rows, Cols>(expr_type(lhs, rhs.const_ref())); \
madcowswe 15:9c5aaeda36dc 1011 } \
madcowswe 15:9c5aaeda36dc 1012 \
madcowswe 15:9c5aaeda36dc 1013 template<class T, std::size_t Rows, std::size_t Cols, \
madcowswe 15:9c5aaeda36dc 1014 class E> \
madcowswe 15:9c5aaeda36dc 1015 inline \
madcowswe 15:9c5aaeda36dc 1016 XprMatrix< \
madcowswe 15:9c5aaeda36dc 1017 XprBinOp< \
madcowswe 15:9c5aaeda36dc 1018 Fcnl_##NAME<typename E::value_type, T>, \
madcowswe 15:9c5aaeda36dc 1019 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1020 XprMatrix<E, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1021 >, \
madcowswe 15:9c5aaeda36dc 1022 Rows, Cols \
madcowswe 15:9c5aaeda36dc 1023 > \
madcowswe 15:9c5aaeda36dc 1024 operator OP (const Matrix<T, Rows, Cols>& lhs, const XprMatrix<E, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 1025 typedef XprBinOp< \
madcowswe 15:9c5aaeda36dc 1026 Fcnl_##NAME<T, typename E::value_type>, \
madcowswe 15:9c5aaeda36dc 1027 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1028 XprMatrix<E, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1029 > expr_type; \
madcowswe 15:9c5aaeda36dc 1030 return XprMatrix<expr_type, Rows, Cols>(expr_type(lhs.const_ref(), rhs)); \
madcowswe 15:9c5aaeda36dc 1031 }
madcowswe 15:9c5aaeda36dc 1032
madcowswe 15:9c5aaeda36dc 1033 // integer operators only, e.g used on double you wil get an error
madcowswe 15:9c5aaeda36dc 1034 namespace element_wise {
madcowswe 15:9c5aaeda36dc 1035 TVMET_IMPLEMENT_MACRO(mod, %)
madcowswe 15:9c5aaeda36dc 1036 TVMET_IMPLEMENT_MACRO(bitxor, ^)
madcowswe 15:9c5aaeda36dc 1037 TVMET_IMPLEMENT_MACRO(bitand, &)
madcowswe 15:9c5aaeda36dc 1038 TVMET_IMPLEMENT_MACRO(bitor, |)
madcowswe 15:9c5aaeda36dc 1039 TVMET_IMPLEMENT_MACRO(shl, <<)
madcowswe 15:9c5aaeda36dc 1040 TVMET_IMPLEMENT_MACRO(shr, >>)
madcowswe 15:9c5aaeda36dc 1041 }
madcowswe 15:9c5aaeda36dc 1042
madcowswe 15:9c5aaeda36dc 1043 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 1044 TVMET_IMPLEMENT_MACRO(greater, >)
madcowswe 15:9c5aaeda36dc 1045 TVMET_IMPLEMENT_MACRO(less, <)
madcowswe 15:9c5aaeda36dc 1046 TVMET_IMPLEMENT_MACRO(greater_eq, >=)
madcowswe 15:9c5aaeda36dc 1047 TVMET_IMPLEMENT_MACRO(less_eq, <=)
madcowswe 15:9c5aaeda36dc 1048 TVMET_IMPLEMENT_MACRO(eq, ==)
madcowswe 15:9c5aaeda36dc 1049 TVMET_IMPLEMENT_MACRO(not_eq, !=)
madcowswe 15:9c5aaeda36dc 1050 TVMET_IMPLEMENT_MACRO(and, &&)
madcowswe 15:9c5aaeda36dc 1051 TVMET_IMPLEMENT_MACRO(or, ||)
madcowswe 15:9c5aaeda36dc 1052
madcowswe 15:9c5aaeda36dc 1053 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 1054
madcowswe 15:9c5aaeda36dc 1055
madcowswe 15:9c5aaeda36dc 1056 #if defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 1057 /*
madcowswe 15:9c5aaeda36dc 1058 * operator(Matrix<T, Rows, Cols>, complex<T>)
madcowswe 15:9c5aaeda36dc 1059 * operator(complex<T>, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 1060 * Note: - per se element wise
madcowswe 15:9c5aaeda36dc 1061 * - bit ops on complex<int> doesn't make sense, stay away
madcowswe 15:9c5aaeda36dc 1062 * \todo type promotion
madcowswe 15:9c5aaeda36dc 1063 */
madcowswe 15:9c5aaeda36dc 1064 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 1065 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 1066 inline \
madcowswe 15:9c5aaeda36dc 1067 XprMatrix< \
madcowswe 15:9c5aaeda36dc 1068 XprBinOp< \
madcowswe 15:9c5aaeda36dc 1069 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 1070 MatrixConstReference< std::complex<T>, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1071 XprLiteral<std::complex<T> > \
madcowswe 15:9c5aaeda36dc 1072 >, \
madcowswe 15:9c5aaeda36dc 1073 Rows, Cols \
madcowswe 15:9c5aaeda36dc 1074 > \
madcowswe 15:9c5aaeda36dc 1075 operator OP (const Matrix< std::complex<T>, Rows, Cols>& lhs, \
madcowswe 15:9c5aaeda36dc 1076 const std::complex<T>& rhs) { \
madcowswe 15:9c5aaeda36dc 1077 typedef XprBinOp< \
madcowswe 15:9c5aaeda36dc 1078 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 1079 MatrixConstReference< std::complex<T>, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1080 XprLiteral< std::complex<T> > \
madcowswe 15:9c5aaeda36dc 1081 > expr_type; \
madcowswe 15:9c5aaeda36dc 1082 return XprMatrix<expr_type, Rows, Cols>( \
madcowswe 15:9c5aaeda36dc 1083 expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs))); \
madcowswe 15:9c5aaeda36dc 1084 } \
madcowswe 15:9c5aaeda36dc 1085 \
madcowswe 15:9c5aaeda36dc 1086 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 1087 inline \
madcowswe 15:9c5aaeda36dc 1088 XprMatrix< \
madcowswe 15:9c5aaeda36dc 1089 XprBinOp< \
madcowswe 15:9c5aaeda36dc 1090 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 1091 XprLiteral< std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 1092 MatrixConstReference< std::complex<T>, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1093 >, \
madcowswe 15:9c5aaeda36dc 1094 Rows, Cols \
madcowswe 15:9c5aaeda36dc 1095 > \
madcowswe 15:9c5aaeda36dc 1096 operator OP (const std::complex<T>& lhs, \
madcowswe 15:9c5aaeda36dc 1097 const Matrix< std::complex<T>, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 1098 typedef XprBinOp< \
madcowswe 15:9c5aaeda36dc 1099 Fcnl_##NAME< std::complex<T>, std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 1100 XprLiteral< std::complex<T> >, \
madcowswe 15:9c5aaeda36dc 1101 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1102 > expr_type; \
madcowswe 15:9c5aaeda36dc 1103 return XprMatrix<expr_type, Rows, Cols>( \
madcowswe 15:9c5aaeda36dc 1104 expr_type(XprLiteral< std::complex<T> >(lhs), rhs.const_ref())); \
madcowswe 15:9c5aaeda36dc 1105 }
madcowswe 15:9c5aaeda36dc 1106
madcowswe 15:9c5aaeda36dc 1107 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 1108 TVMET_IMPLEMENT_MACRO(greater, >)
madcowswe 15:9c5aaeda36dc 1109 TVMET_IMPLEMENT_MACRO(less, <)
madcowswe 15:9c5aaeda36dc 1110 TVMET_IMPLEMENT_MACRO(greater_eq, >=)
madcowswe 15:9c5aaeda36dc 1111 TVMET_IMPLEMENT_MACRO(less_eq, <=)
madcowswe 15:9c5aaeda36dc 1112 TVMET_IMPLEMENT_MACRO(eq, ==)
madcowswe 15:9c5aaeda36dc 1113 TVMET_IMPLEMENT_MACRO(not_eq, !=)
madcowswe 15:9c5aaeda36dc 1114 TVMET_IMPLEMENT_MACRO(and, &&)
madcowswe 15:9c5aaeda36dc 1115 TVMET_IMPLEMENT_MACRO(or, ||)
madcowswe 15:9c5aaeda36dc 1116
madcowswe 15:9c5aaeda36dc 1117 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 1118
madcowswe 15:9c5aaeda36dc 1119 #endif // defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 1120
madcowswe 15:9c5aaeda36dc 1121
madcowswe 15:9c5aaeda36dc 1122 /*
madcowswe 15:9c5aaeda36dc 1123 * operator(Matrix<T, Rows, Cols>, POD)
madcowswe 15:9c5aaeda36dc 1124 * operator(POD, Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 1125 * Note: operations are per se element wise
madcowswe 15:9c5aaeda36dc 1126 */
madcowswe 15:9c5aaeda36dc 1127 #define TVMET_IMPLEMENT_MACRO(NAME, OP, TP) \
madcowswe 15:9c5aaeda36dc 1128 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 1129 inline \
madcowswe 15:9c5aaeda36dc 1130 XprMatrix< \
madcowswe 15:9c5aaeda36dc 1131 XprBinOp< \
madcowswe 15:9c5aaeda36dc 1132 Fcnl_##NAME<T, TP >, \
madcowswe 15:9c5aaeda36dc 1133 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1134 XprLiteral<TP > \
madcowswe 15:9c5aaeda36dc 1135 >, \
madcowswe 15:9c5aaeda36dc 1136 Rows, Cols \
madcowswe 15:9c5aaeda36dc 1137 > \
madcowswe 15:9c5aaeda36dc 1138 operator OP (const Matrix<T, Rows, Cols>& lhs, TP rhs) { \
madcowswe 15:9c5aaeda36dc 1139 typedef XprBinOp< \
madcowswe 15:9c5aaeda36dc 1140 Fcnl_##NAME<T, TP >, \
madcowswe 15:9c5aaeda36dc 1141 MatrixConstReference<T, Rows, Cols>, \
madcowswe 15:9c5aaeda36dc 1142 XprLiteral< TP > \
madcowswe 15:9c5aaeda36dc 1143 > expr_type; \
madcowswe 15:9c5aaeda36dc 1144 return XprMatrix<expr_type, Rows, Cols>( \
madcowswe 15:9c5aaeda36dc 1145 expr_type(lhs.const_ref(), XprLiteral< TP >(rhs))); \
madcowswe 15:9c5aaeda36dc 1146 } \
madcowswe 15:9c5aaeda36dc 1147 \
madcowswe 15:9c5aaeda36dc 1148 template<class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 1149 inline \
madcowswe 15:9c5aaeda36dc 1150 XprMatrix< \
madcowswe 15:9c5aaeda36dc 1151 XprBinOp< \
madcowswe 15:9c5aaeda36dc 1152 Fcnl_##NAME< TP, T>, \
madcowswe 15:9c5aaeda36dc 1153 XprLiteral< TP >, \
madcowswe 15:9c5aaeda36dc 1154 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1155 >, \
madcowswe 15:9c5aaeda36dc 1156 Rows, Cols \
madcowswe 15:9c5aaeda36dc 1157 > \
madcowswe 15:9c5aaeda36dc 1158 operator OP (TP lhs, const Matrix<T, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 1159 typedef XprBinOp< \
madcowswe 15:9c5aaeda36dc 1160 Fcnl_##NAME< TP, T>, \
madcowswe 15:9c5aaeda36dc 1161 XprLiteral< TP >, \
madcowswe 15:9c5aaeda36dc 1162 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1163 > expr_type; \
madcowswe 15:9c5aaeda36dc 1164 return XprMatrix<expr_type, Rows, Cols>( \
madcowswe 15:9c5aaeda36dc 1165 expr_type(XprLiteral< TP >(lhs), rhs.const_ref())); \
madcowswe 15:9c5aaeda36dc 1166 }
madcowswe 15:9c5aaeda36dc 1167
madcowswe 15:9c5aaeda36dc 1168 // integer operators only, e.g used on double you wil get an error
madcowswe 15:9c5aaeda36dc 1169 namespace element_wise {
madcowswe 15:9c5aaeda36dc 1170 TVMET_IMPLEMENT_MACRO(mod, %, int)
madcowswe 15:9c5aaeda36dc 1171 TVMET_IMPLEMENT_MACRO(bitxor, ^, int)
madcowswe 15:9c5aaeda36dc 1172 TVMET_IMPLEMENT_MACRO(bitand, &, int)
madcowswe 15:9c5aaeda36dc 1173 TVMET_IMPLEMENT_MACRO(bitor, |, int)
madcowswe 15:9c5aaeda36dc 1174 TVMET_IMPLEMENT_MACRO(shl, <<, int)
madcowswe 15:9c5aaeda36dc 1175 TVMET_IMPLEMENT_MACRO(shr, >>, int)
madcowswe 15:9c5aaeda36dc 1176 }
madcowswe 15:9c5aaeda36dc 1177
madcowswe 15:9c5aaeda36dc 1178 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 1179 TVMET_IMPLEMENT_MACRO(greater, >, int)
madcowswe 15:9c5aaeda36dc 1180 TVMET_IMPLEMENT_MACRO(less, <, int)
madcowswe 15:9c5aaeda36dc 1181 TVMET_IMPLEMENT_MACRO(greater_eq, >=, int)
madcowswe 15:9c5aaeda36dc 1182 TVMET_IMPLEMENT_MACRO(less_eq, <=, int)
madcowswe 15:9c5aaeda36dc 1183 TVMET_IMPLEMENT_MACRO(eq, ==, int)
madcowswe 15:9c5aaeda36dc 1184 TVMET_IMPLEMENT_MACRO(not_eq, !=, int)
madcowswe 15:9c5aaeda36dc 1185 TVMET_IMPLEMENT_MACRO(and, &&, int)
madcowswe 15:9c5aaeda36dc 1186 TVMET_IMPLEMENT_MACRO(or, ||, int)
madcowswe 15:9c5aaeda36dc 1187
madcowswe 15:9c5aaeda36dc 1188 #if defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 1189 // integer operators only
madcowswe 15:9c5aaeda36dc 1190 namespace element_wise {
madcowswe 15:9c5aaeda36dc 1191 TVMET_IMPLEMENT_MACRO(mod, %, long long int)
madcowswe 15:9c5aaeda36dc 1192 TVMET_IMPLEMENT_MACRO(bitxor, ^, long long int)
madcowswe 15:9c5aaeda36dc 1193 TVMET_IMPLEMENT_MACRO(bitand, &, long long int)
madcowswe 15:9c5aaeda36dc 1194 TVMET_IMPLEMENT_MACRO(bitor, |, long long int)
madcowswe 15:9c5aaeda36dc 1195 TVMET_IMPLEMENT_MACRO(shl, <<, long long int)
madcowswe 15:9c5aaeda36dc 1196 TVMET_IMPLEMENT_MACRO(shr, >>, long long int)
madcowswe 15:9c5aaeda36dc 1197 }
madcowswe 15:9c5aaeda36dc 1198
madcowswe 15:9c5aaeda36dc 1199 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 1200 TVMET_IMPLEMENT_MACRO(greater, >, long long int)
madcowswe 15:9c5aaeda36dc 1201 TVMET_IMPLEMENT_MACRO(less, <, long long int)
madcowswe 15:9c5aaeda36dc 1202 TVMET_IMPLEMENT_MACRO(greater_eq, >=, long long int)
madcowswe 15:9c5aaeda36dc 1203 TVMET_IMPLEMENT_MACRO(less_eq, <=, long long int)
madcowswe 15:9c5aaeda36dc 1204 TVMET_IMPLEMENT_MACRO(eq, ==, long long int)
madcowswe 15:9c5aaeda36dc 1205 TVMET_IMPLEMENT_MACRO(not_eq, !=, long long int)
madcowswe 15:9c5aaeda36dc 1206 TVMET_IMPLEMENT_MACRO(and, &&, long long int)
madcowswe 15:9c5aaeda36dc 1207 TVMET_IMPLEMENT_MACRO(or, ||, long long int)
madcowswe 15:9c5aaeda36dc 1208 #endif // defined(TVMET_HAVE_LONG_LONG)
madcowswe 15:9c5aaeda36dc 1209
madcowswe 15:9c5aaeda36dc 1210 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 1211 TVMET_IMPLEMENT_MACRO(greater, >, float)
madcowswe 15:9c5aaeda36dc 1212 TVMET_IMPLEMENT_MACRO(less, <, float)
madcowswe 15:9c5aaeda36dc 1213 TVMET_IMPLEMENT_MACRO(greater_eq, >=, float)
madcowswe 15:9c5aaeda36dc 1214 TVMET_IMPLEMENT_MACRO(less_eq, <=, float)
madcowswe 15:9c5aaeda36dc 1215 TVMET_IMPLEMENT_MACRO(eq, ==, float)
madcowswe 15:9c5aaeda36dc 1216 TVMET_IMPLEMENT_MACRO(not_eq, !=, float)
madcowswe 15:9c5aaeda36dc 1217 TVMET_IMPLEMENT_MACRO(and, &&, float)
madcowswe 15:9c5aaeda36dc 1218 TVMET_IMPLEMENT_MACRO(or, ||, float)
madcowswe 15:9c5aaeda36dc 1219
madcowswe 15:9c5aaeda36dc 1220 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 1221 TVMET_IMPLEMENT_MACRO(greater, >, double)
madcowswe 15:9c5aaeda36dc 1222 TVMET_IMPLEMENT_MACRO(less, <, double)
madcowswe 15:9c5aaeda36dc 1223 TVMET_IMPLEMENT_MACRO(greater_eq, >=, double)
madcowswe 15:9c5aaeda36dc 1224 TVMET_IMPLEMENT_MACRO(less_eq, <=, double)
madcowswe 15:9c5aaeda36dc 1225 TVMET_IMPLEMENT_MACRO(eq, ==, double)
madcowswe 15:9c5aaeda36dc 1226 TVMET_IMPLEMENT_MACRO(not_eq, !=, double)
madcowswe 15:9c5aaeda36dc 1227 TVMET_IMPLEMENT_MACRO(and, &&, double)
madcowswe 15:9c5aaeda36dc 1228 TVMET_IMPLEMENT_MACRO(or, ||, double)
madcowswe 15:9c5aaeda36dc 1229
madcowswe 15:9c5aaeda36dc 1230 #if defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 1231 // necessary operators for eval functions
madcowswe 15:9c5aaeda36dc 1232 TVMET_IMPLEMENT_MACRO(greater, >, long double)
madcowswe 15:9c5aaeda36dc 1233 TVMET_IMPLEMENT_MACRO(less, <, long double)
madcowswe 15:9c5aaeda36dc 1234 TVMET_IMPLEMENT_MACRO(greater_eq, >=, long double)
madcowswe 15:9c5aaeda36dc 1235 TVMET_IMPLEMENT_MACRO(less_eq, <=, long double)
madcowswe 15:9c5aaeda36dc 1236 TVMET_IMPLEMENT_MACRO(eq, ==, long double)
madcowswe 15:9c5aaeda36dc 1237 TVMET_IMPLEMENT_MACRO(not_eq, !=, long double)
madcowswe 15:9c5aaeda36dc 1238 TVMET_IMPLEMENT_MACRO(and, &&, long double)
madcowswe 15:9c5aaeda36dc 1239 TVMET_IMPLEMENT_MACRO(or, ||, long double)
madcowswe 15:9c5aaeda36dc 1240 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
madcowswe 15:9c5aaeda36dc 1241
madcowswe 15:9c5aaeda36dc 1242 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 1243
madcowswe 15:9c5aaeda36dc 1244
madcowswe 15:9c5aaeda36dc 1245
madcowswe 15:9c5aaeda36dc 1246
madcowswe 15:9c5aaeda36dc 1247 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
madcowswe 15:9c5aaeda36dc 1248 * global unary operators
madcowswe 15:9c5aaeda36dc 1249 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
madcowswe 15:9c5aaeda36dc 1250
madcowswe 15:9c5aaeda36dc 1251
madcowswe 15:9c5aaeda36dc 1252 /*
madcowswe 15:9c5aaeda36dc 1253 * unary_operator(Matrix<T, Rows, Cols>)
madcowswe 15:9c5aaeda36dc 1254 * Note: per se element wise
madcowswe 15:9c5aaeda36dc 1255 */
madcowswe 15:9c5aaeda36dc 1256 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 1257 template <class T, std::size_t Rows, std::size_t Cols> \
madcowswe 15:9c5aaeda36dc 1258 inline \
madcowswe 15:9c5aaeda36dc 1259 XprMatrix< \
madcowswe 15:9c5aaeda36dc 1260 XprUnOp< \
madcowswe 15:9c5aaeda36dc 1261 Fcnl_##NAME<T>, \
madcowswe 15:9c5aaeda36dc 1262 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1263 >, \
madcowswe 15:9c5aaeda36dc 1264 Rows, Cols \
madcowswe 15:9c5aaeda36dc 1265 > \
madcowswe 15:9c5aaeda36dc 1266 operator OP (const Matrix<T, Rows, Cols>& rhs) { \
madcowswe 15:9c5aaeda36dc 1267 typedef XprUnOp< \
madcowswe 15:9c5aaeda36dc 1268 Fcnl_##NAME<T>, \
madcowswe 15:9c5aaeda36dc 1269 MatrixConstReference<T, Rows, Cols> \
madcowswe 15:9c5aaeda36dc 1270 > expr_type; \
madcowswe 15:9c5aaeda36dc 1271 return XprMatrix<expr_type, Rows, Cols>(expr_type(rhs.const_ref())); \
madcowswe 15:9c5aaeda36dc 1272 }
madcowswe 15:9c5aaeda36dc 1273
madcowswe 15:9c5aaeda36dc 1274 TVMET_IMPLEMENT_MACRO(not, !)
madcowswe 15:9c5aaeda36dc 1275 TVMET_IMPLEMENT_MACRO(compl, ~)
madcowswe 15:9c5aaeda36dc 1276 TVMET_IMPLEMENT_MACRO(neg, -)
madcowswe 15:9c5aaeda36dc 1277 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 1278
madcowswe 15:9c5aaeda36dc 1279
madcowswe 15:9c5aaeda36dc 1280 } // namespace tvmet
madcowswe 15:9c5aaeda36dc 1281
madcowswe 15:9c5aaeda36dc 1282 #endif // TVMET_MATRIX_OPERATORS_H
madcowswe 15:9c5aaeda36dc 1283
madcowswe 15:9c5aaeda36dc 1284 // Local Variables:
madcowswe 15:9c5aaeda36dc 1285 // mode:C++
madcowswe 15:9c5aaeda36dc 1286 // tab-width:8
madcowswe 15:9c5aaeda36dc 1287 // End: