Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Wed Oct 17 22:22:47 2012 +0000
Revision:
26:0995f61cb7b8
Parent:
25:143b19c1fb05
Eurobot 2012 Primary;

Who changed what in which revision?

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