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