![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
tvmet/MatrixEval.h@15:9c5aaeda36dc, 2013-04-06 (annotated)
- Committer:
- madcowswe
- Date:
- Sat Apr 06 20:57:54 2013 +0000
- Revision:
- 15:9c5aaeda36dc
Encoders fairly tuned, still has random noise in it
Who changed what in which revision?
User | Revision | Line number | New 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: MatrixEval.h,v 1.18 2007-06-23 15:58:58 opetzold Exp $ |
madcowswe | 15:9c5aaeda36dc | 22 | */ |
madcowswe | 15:9c5aaeda36dc | 23 | |
madcowswe | 15:9c5aaeda36dc | 24 | #ifndef TVMET_MATRIX_EVAL_H |
madcowswe | 15:9c5aaeda36dc | 25 | #define TVMET_MATRIX_EVAL_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 | * \fn bool all_elements(const XprMatrix<E, Rows, Cols>& e) |
madcowswe | 15:9c5aaeda36dc | 32 | * \brief check on statements for all elements |
madcowswe | 15:9c5aaeda36dc | 33 | * \ingroup _unary_function |
madcowswe | 15:9c5aaeda36dc | 34 | * This is for use with boolean operators like |
madcowswe | 15:9c5aaeda36dc | 35 | * \par Example: |
madcowswe | 15:9c5aaeda36dc | 36 | * \code |
madcowswe | 15:9c5aaeda36dc | 37 | * all_elements(matrix > 0) { |
madcowswe | 15:9c5aaeda36dc | 38 | * // true branch |
madcowswe | 15:9c5aaeda36dc | 39 | * } else { |
madcowswe | 15:9c5aaeda36dc | 40 | * // false branch |
madcowswe | 15:9c5aaeda36dc | 41 | * } |
madcowswe | 15:9c5aaeda36dc | 42 | * \endcode |
madcowswe | 15:9c5aaeda36dc | 43 | * \sa \ref compare |
madcowswe | 15:9c5aaeda36dc | 44 | */ |
madcowswe | 15:9c5aaeda36dc | 45 | template<class E, std::size_t Rows, std::size_t Cols> |
madcowswe | 15:9c5aaeda36dc | 46 | inline |
madcowswe | 15:9c5aaeda36dc | 47 | bool all_elements(const XprMatrix<E, Rows, Cols>& e) { |
madcowswe | 15:9c5aaeda36dc | 48 | return meta::Matrix<Rows, Cols, 0, 0>::all_elements(e); |
madcowswe | 15:9c5aaeda36dc | 49 | } |
madcowswe | 15:9c5aaeda36dc | 50 | |
madcowswe | 15:9c5aaeda36dc | 51 | |
madcowswe | 15:9c5aaeda36dc | 52 | /** |
madcowswe | 15:9c5aaeda36dc | 53 | * \fn bool any_elements(const XprMatrix<E, Rows, Cols>& e) |
madcowswe | 15:9c5aaeda36dc | 54 | * \brief check on statements for any elements |
madcowswe | 15:9c5aaeda36dc | 55 | * \ingroup _unary_function |
madcowswe | 15:9c5aaeda36dc | 56 | * This is for use with boolean operators like |
madcowswe | 15:9c5aaeda36dc | 57 | * \par Example: |
madcowswe | 15:9c5aaeda36dc | 58 | * \code |
madcowswe | 15:9c5aaeda36dc | 59 | * any_elements(matrix > 0) { |
madcowswe | 15:9c5aaeda36dc | 60 | * // true branch |
madcowswe | 15:9c5aaeda36dc | 61 | * } else { |
madcowswe | 15:9c5aaeda36dc | 62 | * // false branch |
madcowswe | 15:9c5aaeda36dc | 63 | * } |
madcowswe | 15:9c5aaeda36dc | 64 | * \endcode |
madcowswe | 15:9c5aaeda36dc | 65 | * \sa \ref compare |
madcowswe | 15:9c5aaeda36dc | 66 | */ |
madcowswe | 15:9c5aaeda36dc | 67 | template<class E, std::size_t Rows, std::size_t Cols> |
madcowswe | 15:9c5aaeda36dc | 68 | inline |
madcowswe | 15:9c5aaeda36dc | 69 | bool any_elements(const XprMatrix<E, Rows, Cols>& e) { |
madcowswe | 15:9c5aaeda36dc | 70 | return meta::Matrix<Rows, Cols, 0, 0>::any_elements(e); |
madcowswe | 15:9c5aaeda36dc | 71 | } |
madcowswe | 15:9c5aaeda36dc | 72 | |
madcowswe | 15:9c5aaeda36dc | 73 | |
madcowswe | 15:9c5aaeda36dc | 74 | /* |
madcowswe | 15:9c5aaeda36dc | 75 | * trinary evaluation functions with matrizes and xpr of |
madcowswe | 15:9c5aaeda36dc | 76 | * |
madcowswe | 15:9c5aaeda36dc | 77 | * XprMatrix<E1, Rows, Cols> ? Matrix<T2, Rows, Cols> : Matrix<T3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 78 | * XprMatrix<E1, Rows, Cols> ? Matrix<T2, Rows, Cols> : XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 79 | * XprMatrix<E1, Rows, Cols> ? XprMatrix<E2, Rows, Cols> : Matrix<T3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 80 | * XprMatrix<E1, Rows, Cols> ? XprMatrix<E2, Rows, Cols> : XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 81 | */ |
madcowswe | 15:9c5aaeda36dc | 82 | |
madcowswe | 15:9c5aaeda36dc | 83 | /** |
madcowswe | 15:9c5aaeda36dc | 84 | * \fn eval(const XprMatrix<E1, Rows, Cols>& e1, const Matrix<T2, Rows, Cols>& m2, const Matrix<T3, Rows, Cols>& m3) |
madcowswe | 15:9c5aaeda36dc | 85 | * \brief Evals the matrix expressions. |
madcowswe | 15:9c5aaeda36dc | 86 | * \ingroup _trinary_function |
madcowswe | 15:9c5aaeda36dc | 87 | * This eval is for the a?b:c syntax, since it's not allowed to overload |
madcowswe | 15:9c5aaeda36dc | 88 | * these operators. |
madcowswe | 15:9c5aaeda36dc | 89 | */ |
madcowswe | 15:9c5aaeda36dc | 90 | template<class E1, class T2, class T3, std::size_t Rows, std::size_t Cols> |
madcowswe | 15:9c5aaeda36dc | 91 | inline |
madcowswe | 15:9c5aaeda36dc | 92 | XprMatrix< |
madcowswe | 15:9c5aaeda36dc | 93 | XprEval< |
madcowswe | 15:9c5aaeda36dc | 94 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 95 | MatrixConstReference<T2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 96 | MatrixConstReference<T3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 97 | >, |
madcowswe | 15:9c5aaeda36dc | 98 | Rows, Cols |
madcowswe | 15:9c5aaeda36dc | 99 | > |
madcowswe | 15:9c5aaeda36dc | 100 | eval(const XprMatrix<E1, Rows, Cols>& e1, |
madcowswe | 15:9c5aaeda36dc | 101 | const Matrix<T2, Rows, Cols>& m2, |
madcowswe | 15:9c5aaeda36dc | 102 | const Matrix<T3, Rows, Cols>& m3) { |
madcowswe | 15:9c5aaeda36dc | 103 | typedef XprEval< |
madcowswe | 15:9c5aaeda36dc | 104 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 105 | MatrixConstReference<T2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 106 | MatrixConstReference<T3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 107 | > expr_type; |
madcowswe | 15:9c5aaeda36dc | 108 | return XprMatrix<expr_type, Rows, Cols>( |
madcowswe | 15:9c5aaeda36dc | 109 | expr_type(e1, m2.const_ref(), m3.const_ref())); |
madcowswe | 15:9c5aaeda36dc | 110 | } |
madcowswe | 15:9c5aaeda36dc | 111 | |
madcowswe | 15:9c5aaeda36dc | 112 | |
madcowswe | 15:9c5aaeda36dc | 113 | /** |
madcowswe | 15:9c5aaeda36dc | 114 | * \fn eval(const XprMatrix<E1, Rows, Cols>& e1, const Matrix<T2, Rows, Cols>& m2, const XprMatrix<E3, Rows, Cols>& e3) |
madcowswe | 15:9c5aaeda36dc | 115 | * \brief Evals the matrix expressions. |
madcowswe | 15:9c5aaeda36dc | 116 | * \ingroup _trinary_function |
madcowswe | 15:9c5aaeda36dc | 117 | * This eval is for the a?b:c syntax, since it's not allowed to overload |
madcowswe | 15:9c5aaeda36dc | 118 | * these operators. |
madcowswe | 15:9c5aaeda36dc | 119 | */ |
madcowswe | 15:9c5aaeda36dc | 120 | template<class E1, class T2, class E3, std::size_t Rows, std::size_t Cols> |
madcowswe | 15:9c5aaeda36dc | 121 | inline |
madcowswe | 15:9c5aaeda36dc | 122 | XprMatrix< |
madcowswe | 15:9c5aaeda36dc | 123 | XprEval< |
madcowswe | 15:9c5aaeda36dc | 124 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 125 | MatrixConstReference<T2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 126 | XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 127 | >, |
madcowswe | 15:9c5aaeda36dc | 128 | Rows, Cols |
madcowswe | 15:9c5aaeda36dc | 129 | > |
madcowswe | 15:9c5aaeda36dc | 130 | eval(const XprMatrix<E1, Rows, Cols>& e1, |
madcowswe | 15:9c5aaeda36dc | 131 | const Matrix<T2, Rows, Cols>& m2, |
madcowswe | 15:9c5aaeda36dc | 132 | const XprMatrix<E3, Rows, Cols>& e3) { |
madcowswe | 15:9c5aaeda36dc | 133 | typedef XprEval< |
madcowswe | 15:9c5aaeda36dc | 134 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 135 | MatrixConstReference<T2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 136 | XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 137 | > expr_type; |
madcowswe | 15:9c5aaeda36dc | 138 | return XprMatrix<expr_type, Rows, Cols>( |
madcowswe | 15:9c5aaeda36dc | 139 | expr_type(e1, m2.const_ref(), e3)); |
madcowswe | 15:9c5aaeda36dc | 140 | } |
madcowswe | 15:9c5aaeda36dc | 141 | |
madcowswe | 15:9c5aaeda36dc | 142 | |
madcowswe | 15:9c5aaeda36dc | 143 | /** |
madcowswe | 15:9c5aaeda36dc | 144 | * \fn eval(const XprMatrix<E1, Rows, Cols>& e1, const XprMatrix<E2, Rows, Cols>& e2, const Matrix<T3, Rows, Cols>& m3) |
madcowswe | 15:9c5aaeda36dc | 145 | * \brief Evals the matrix expressions. |
madcowswe | 15:9c5aaeda36dc | 146 | * \ingroup _trinary_function |
madcowswe | 15:9c5aaeda36dc | 147 | * This eval is for the a?b:c syntax, since it's not allowed to overload |
madcowswe | 15:9c5aaeda36dc | 148 | * these operators. |
madcowswe | 15:9c5aaeda36dc | 149 | */ |
madcowswe | 15:9c5aaeda36dc | 150 | template<class E1, class E2, class T3, std::size_t Rows, std::size_t Cols> |
madcowswe | 15:9c5aaeda36dc | 151 | inline |
madcowswe | 15:9c5aaeda36dc | 152 | XprMatrix< |
madcowswe | 15:9c5aaeda36dc | 153 | XprEval< |
madcowswe | 15:9c5aaeda36dc | 154 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 155 | XprMatrix<E2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 156 | MatrixConstReference<T3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 157 | >, |
madcowswe | 15:9c5aaeda36dc | 158 | Rows, Cols |
madcowswe | 15:9c5aaeda36dc | 159 | > |
madcowswe | 15:9c5aaeda36dc | 160 | eval(const XprMatrix<E1, Rows, Cols>& e1, |
madcowswe | 15:9c5aaeda36dc | 161 | const XprMatrix<E2, Rows, Cols>& e2, |
madcowswe | 15:9c5aaeda36dc | 162 | const Matrix<T3, Rows, Cols>& m3) { |
madcowswe | 15:9c5aaeda36dc | 163 | typedef XprEval< |
madcowswe | 15:9c5aaeda36dc | 164 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 165 | XprMatrix<E2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 166 | MatrixConstReference<T3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 167 | > expr_type; |
madcowswe | 15:9c5aaeda36dc | 168 | return XprMatrix<expr_type, Rows, Cols>( |
madcowswe | 15:9c5aaeda36dc | 169 | expr_type(e1, e2, m3.const_ref())); |
madcowswe | 15:9c5aaeda36dc | 170 | } |
madcowswe | 15:9c5aaeda36dc | 171 | |
madcowswe | 15:9c5aaeda36dc | 172 | |
madcowswe | 15:9c5aaeda36dc | 173 | /** |
madcowswe | 15:9c5aaeda36dc | 174 | * \fn eval(const XprMatrix<E1, Rows, Cols>& e1, const XprMatrix<E2, Rows, Cols>& e2, const XprMatrix<E3, Rows, Cols>& e3) |
madcowswe | 15:9c5aaeda36dc | 175 | * \brief Evals the matrix expressions. |
madcowswe | 15:9c5aaeda36dc | 176 | * \ingroup _trinary_function |
madcowswe | 15:9c5aaeda36dc | 177 | * This eval is for the a?b:c syntax, since it's not allowed to overload |
madcowswe | 15:9c5aaeda36dc | 178 | * these operators. |
madcowswe | 15:9c5aaeda36dc | 179 | */ |
madcowswe | 15:9c5aaeda36dc | 180 | template<class E1, class E2, class E3, std::size_t Rows, std::size_t Cols> |
madcowswe | 15:9c5aaeda36dc | 181 | inline |
madcowswe | 15:9c5aaeda36dc | 182 | XprMatrix< |
madcowswe | 15:9c5aaeda36dc | 183 | XprEval< |
madcowswe | 15:9c5aaeda36dc | 184 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 185 | XprMatrix<E2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 186 | XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 187 | >, |
madcowswe | 15:9c5aaeda36dc | 188 | Rows, Cols |
madcowswe | 15:9c5aaeda36dc | 189 | > |
madcowswe | 15:9c5aaeda36dc | 190 | eval(const XprMatrix<E1, Rows, Cols>& e1, |
madcowswe | 15:9c5aaeda36dc | 191 | const XprMatrix<E2, Rows, Cols>& e2, |
madcowswe | 15:9c5aaeda36dc | 192 | const XprMatrix<E3, Rows, Cols>& e3) { |
madcowswe | 15:9c5aaeda36dc | 193 | typedef XprEval< |
madcowswe | 15:9c5aaeda36dc | 194 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 195 | XprMatrix<E2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 196 | XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 197 | > expr_type; |
madcowswe | 15:9c5aaeda36dc | 198 | return XprMatrix<expr_type, Rows, Cols>(expr_type(e1, e2, e3)); |
madcowswe | 15:9c5aaeda36dc | 199 | } |
madcowswe | 15:9c5aaeda36dc | 200 | |
madcowswe | 15:9c5aaeda36dc | 201 | |
madcowswe | 15:9c5aaeda36dc | 202 | /* |
madcowswe | 15:9c5aaeda36dc | 203 | * trinary evaluation functions with matrizes, xpr of and POD |
madcowswe | 15:9c5aaeda36dc | 204 | * |
madcowswe | 15:9c5aaeda36dc | 205 | * XprMatrix<E, Rows, Cols> ? POD1 : POD2 |
madcowswe | 15:9c5aaeda36dc | 206 | * XprMatrix<E1, Rows, Cols> ? POD : XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 207 | * XprMatrix<E1, Rows, Cols> ? XprMatrix<E2, Rows, Cols> : POD |
madcowswe | 15:9c5aaeda36dc | 208 | */ |
madcowswe | 15:9c5aaeda36dc | 209 | #define TVMET_IMPLEMENT_MACRO(POD) \ |
madcowswe | 15:9c5aaeda36dc | 210 | template<class E, std::size_t Rows, std::size_t Cols> \ |
madcowswe | 15:9c5aaeda36dc | 211 | inline \ |
madcowswe | 15:9c5aaeda36dc | 212 | XprMatrix< \ |
madcowswe | 15:9c5aaeda36dc | 213 | XprEval< \ |
madcowswe | 15:9c5aaeda36dc | 214 | XprMatrix<E, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 215 | XprLiteral< POD >, \ |
madcowswe | 15:9c5aaeda36dc | 216 | XprLiteral< POD > \ |
madcowswe | 15:9c5aaeda36dc | 217 | >, \ |
madcowswe | 15:9c5aaeda36dc | 218 | Rows, Cols \ |
madcowswe | 15:9c5aaeda36dc | 219 | > \ |
madcowswe | 15:9c5aaeda36dc | 220 | eval(const XprMatrix<E, Rows, Cols>& e, POD x2, POD x3) { \ |
madcowswe | 15:9c5aaeda36dc | 221 | typedef XprEval< \ |
madcowswe | 15:9c5aaeda36dc | 222 | XprMatrix<E, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 223 | XprLiteral< POD >, \ |
madcowswe | 15:9c5aaeda36dc | 224 | XprLiteral< POD > \ |
madcowswe | 15:9c5aaeda36dc | 225 | > expr_type; \ |
madcowswe | 15:9c5aaeda36dc | 226 | return XprMatrix<expr_type, Rows, Cols>( \ |
madcowswe | 15:9c5aaeda36dc | 227 | expr_type(e, XprLiteral< POD >(x2), XprLiteral< POD >(x3))); \ |
madcowswe | 15:9c5aaeda36dc | 228 | } \ |
madcowswe | 15:9c5aaeda36dc | 229 | \ |
madcowswe | 15:9c5aaeda36dc | 230 | template<class E1, class E3, std::size_t Rows, std::size_t Cols> \ |
madcowswe | 15:9c5aaeda36dc | 231 | inline \ |
madcowswe | 15:9c5aaeda36dc | 232 | XprMatrix< \ |
madcowswe | 15:9c5aaeda36dc | 233 | XprEval< \ |
madcowswe | 15:9c5aaeda36dc | 234 | XprMatrix<E1, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 235 | XprLiteral< POD >, \ |
madcowswe | 15:9c5aaeda36dc | 236 | XprMatrix<E3, Rows, Cols> \ |
madcowswe | 15:9c5aaeda36dc | 237 | >, \ |
madcowswe | 15:9c5aaeda36dc | 238 | Rows, Cols \ |
madcowswe | 15:9c5aaeda36dc | 239 | > \ |
madcowswe | 15:9c5aaeda36dc | 240 | eval(const XprMatrix<E1, Rows, Cols>& e1, POD x2, const XprMatrix<E3, Rows, Cols>& e3) { \ |
madcowswe | 15:9c5aaeda36dc | 241 | typedef XprEval< \ |
madcowswe | 15:9c5aaeda36dc | 242 | XprMatrix<E1, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 243 | XprLiteral< POD >, \ |
madcowswe | 15:9c5aaeda36dc | 244 | XprMatrix<E3, Rows, Cols> \ |
madcowswe | 15:9c5aaeda36dc | 245 | > expr_type; \ |
madcowswe | 15:9c5aaeda36dc | 246 | return XprMatrix<expr_type, Rows, Cols>( \ |
madcowswe | 15:9c5aaeda36dc | 247 | expr_type(e1, XprLiteral< POD >(x2), e3)); \ |
madcowswe | 15:9c5aaeda36dc | 248 | } \ |
madcowswe | 15:9c5aaeda36dc | 249 | \ |
madcowswe | 15:9c5aaeda36dc | 250 | template<class E1, class E2, std::size_t Rows, std::size_t Cols> \ |
madcowswe | 15:9c5aaeda36dc | 251 | inline \ |
madcowswe | 15:9c5aaeda36dc | 252 | XprMatrix< \ |
madcowswe | 15:9c5aaeda36dc | 253 | XprEval< \ |
madcowswe | 15:9c5aaeda36dc | 254 | XprMatrix<E1, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 255 | XprMatrix<E2, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 256 | XprLiteral< POD > \ |
madcowswe | 15:9c5aaeda36dc | 257 | >, \ |
madcowswe | 15:9c5aaeda36dc | 258 | Rows, Cols \ |
madcowswe | 15:9c5aaeda36dc | 259 | > \ |
madcowswe | 15:9c5aaeda36dc | 260 | eval(const XprMatrix<E1, Rows, Cols>& e1, const XprMatrix<E2, Rows, Cols>& e2, POD x3) { \ |
madcowswe | 15:9c5aaeda36dc | 261 | typedef XprEval< \ |
madcowswe | 15:9c5aaeda36dc | 262 | XprMatrix<E1, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 263 | XprMatrix<E2, Rows, Cols>, \ |
madcowswe | 15:9c5aaeda36dc | 264 | XprLiteral< POD > \ |
madcowswe | 15:9c5aaeda36dc | 265 | > expr_type; \ |
madcowswe | 15:9c5aaeda36dc | 266 | return XprMatrix<expr_type, Rows, Cols>( \ |
madcowswe | 15:9c5aaeda36dc | 267 | expr_type(e1, e2, XprLiteral< POD >(x3))); \ |
madcowswe | 15:9c5aaeda36dc | 268 | } |
madcowswe | 15:9c5aaeda36dc | 269 | |
madcowswe | 15:9c5aaeda36dc | 270 | TVMET_IMPLEMENT_MACRO(int) |
madcowswe | 15:9c5aaeda36dc | 271 | |
madcowswe | 15:9c5aaeda36dc | 272 | #if defined(TVMET_HAVE_LONG_LONG) |
madcowswe | 15:9c5aaeda36dc | 273 | TVMET_IMPLEMENT_MACRO(long long int) |
madcowswe | 15:9c5aaeda36dc | 274 | #endif |
madcowswe | 15:9c5aaeda36dc | 275 | |
madcowswe | 15:9c5aaeda36dc | 276 | TVMET_IMPLEMENT_MACRO(float) |
madcowswe | 15:9c5aaeda36dc | 277 | TVMET_IMPLEMENT_MACRO(double) |
madcowswe | 15:9c5aaeda36dc | 278 | |
madcowswe | 15:9c5aaeda36dc | 279 | #if defined(TVMET_HAVE_LONG_DOUBLE) |
madcowswe | 15:9c5aaeda36dc | 280 | TVMET_IMPLEMENT_MACRO(long double) |
madcowswe | 15:9c5aaeda36dc | 281 | #endif |
madcowswe | 15:9c5aaeda36dc | 282 | |
madcowswe | 15:9c5aaeda36dc | 283 | #undef TVMET_IMPLEMENT_MACRO |
madcowswe | 15:9c5aaeda36dc | 284 | |
madcowswe | 15:9c5aaeda36dc | 285 | |
madcowswe | 15:9c5aaeda36dc | 286 | /* |
madcowswe | 15:9c5aaeda36dc | 287 | * trinary evaluation functions with matrizes, xpr of and complex<> types |
madcowswe | 15:9c5aaeda36dc | 288 | * |
madcowswe | 15:9c5aaeda36dc | 289 | * XprMatrix<E, Rows, Cols> e, std::complex<T> z2, std::complex<T> z3 |
madcowswe | 15:9c5aaeda36dc | 290 | * XprMatrix<E1, Rows, Cols> e1, std::complex<T> z2, XprMatrix<E3, Rows, Cols> e3 |
madcowswe | 15:9c5aaeda36dc | 291 | * XprMatrix<E1, Rows, Cols> e1, XprMatrix<E2, Rows, Cols> e2, std::complex<T> z3 |
madcowswe | 15:9c5aaeda36dc | 292 | */ |
madcowswe | 15:9c5aaeda36dc | 293 | #if defined(TVMET_HAVE_COMPLEX) |
madcowswe | 15:9c5aaeda36dc | 294 | |
madcowswe | 15:9c5aaeda36dc | 295 | /** |
madcowswe | 15:9c5aaeda36dc | 296 | * \fn eval(const XprMatrix<E, Rows, Cols>& e, const std::complex<T>& x2, const std::complex<T>& x3) |
madcowswe | 15:9c5aaeda36dc | 297 | * \brief Evals the matrix expressions. |
madcowswe | 15:9c5aaeda36dc | 298 | * \ingroup _trinary_function |
madcowswe | 15:9c5aaeda36dc | 299 | * This eval is for the a?b:c syntax, since it's not allowed to overload |
madcowswe | 15:9c5aaeda36dc | 300 | * these operators. |
madcowswe | 15:9c5aaeda36dc | 301 | */ |
madcowswe | 15:9c5aaeda36dc | 302 | template<class E, std::size_t Rows, std::size_t Cols, class T> |
madcowswe | 15:9c5aaeda36dc | 303 | inline |
madcowswe | 15:9c5aaeda36dc | 304 | XprMatrix< |
madcowswe | 15:9c5aaeda36dc | 305 | XprEval< |
madcowswe | 15:9c5aaeda36dc | 306 | XprMatrix<E, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 307 | XprLiteral< std::complex<T> >, |
madcowswe | 15:9c5aaeda36dc | 308 | XprLiteral< std::complex<T> > |
madcowswe | 15:9c5aaeda36dc | 309 | >, |
madcowswe | 15:9c5aaeda36dc | 310 | Rows, Cols |
madcowswe | 15:9c5aaeda36dc | 311 | > |
madcowswe | 15:9c5aaeda36dc | 312 | eval(const XprMatrix<E, Rows, Cols>& e, const std::complex<T>& x2, const std::complex<T>& x3) { |
madcowswe | 15:9c5aaeda36dc | 313 | typedef XprEval< |
madcowswe | 15:9c5aaeda36dc | 314 | XprMatrix<E, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 315 | XprLiteral< std::complex<T> >, |
madcowswe | 15:9c5aaeda36dc | 316 | XprLiteral< std::complex<T> > |
madcowswe | 15:9c5aaeda36dc | 317 | > expr_type; |
madcowswe | 15:9c5aaeda36dc | 318 | return XprMatrix<expr_type, Rows, Cols>( |
madcowswe | 15:9c5aaeda36dc | 319 | expr_type(e, XprLiteral< std::complex<T> >(x2), XprLiteral< std::complex<T> >(x3))); |
madcowswe | 15:9c5aaeda36dc | 320 | } |
madcowswe | 15:9c5aaeda36dc | 321 | |
madcowswe | 15:9c5aaeda36dc | 322 | |
madcowswe | 15:9c5aaeda36dc | 323 | /** |
madcowswe | 15:9c5aaeda36dc | 324 | * \fn eval(const XprMatrix<E1, Rows, Cols>& e1, const std::complex<T>& x2, const XprMatrix<E3, Rows, Cols>& e3) |
madcowswe | 15:9c5aaeda36dc | 325 | * \brief Evals the matrix expressions. |
madcowswe | 15:9c5aaeda36dc | 326 | * \ingroup _trinary_function |
madcowswe | 15:9c5aaeda36dc | 327 | * This eval is for the a?b:c syntax, since it's not allowed to overload |
madcowswe | 15:9c5aaeda36dc | 328 | * these operators. |
madcowswe | 15:9c5aaeda36dc | 329 | */ |
madcowswe | 15:9c5aaeda36dc | 330 | template<class E1, class E3, std::size_t Rows, std::size_t Cols, class T> |
madcowswe | 15:9c5aaeda36dc | 331 | inline |
madcowswe | 15:9c5aaeda36dc | 332 | XprMatrix< |
madcowswe | 15:9c5aaeda36dc | 333 | XprEval< |
madcowswe | 15:9c5aaeda36dc | 334 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 335 | XprLiteral< std::complex<T> >, |
madcowswe | 15:9c5aaeda36dc | 336 | XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 337 | >, |
madcowswe | 15:9c5aaeda36dc | 338 | Rows, Cols |
madcowswe | 15:9c5aaeda36dc | 339 | > |
madcowswe | 15:9c5aaeda36dc | 340 | eval(const XprMatrix<E1, Rows, Cols>& e1, const std::complex<T>& x2, const XprMatrix<E3, Rows, Cols>& e3) { |
madcowswe | 15:9c5aaeda36dc | 341 | typedef XprEval< |
madcowswe | 15:9c5aaeda36dc | 342 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 343 | XprLiteral< std::complex<T> >, |
madcowswe | 15:9c5aaeda36dc | 344 | XprMatrix<E3, Rows, Cols> |
madcowswe | 15:9c5aaeda36dc | 345 | > expr_type; |
madcowswe | 15:9c5aaeda36dc | 346 | return XprMatrix<expr_type, Rows, Cols>( |
madcowswe | 15:9c5aaeda36dc | 347 | expr_type(e1, XprLiteral< std::complex<T> >(x2), e3)); |
madcowswe | 15:9c5aaeda36dc | 348 | } |
madcowswe | 15:9c5aaeda36dc | 349 | |
madcowswe | 15:9c5aaeda36dc | 350 | |
madcowswe | 15:9c5aaeda36dc | 351 | /** |
madcowswe | 15:9c5aaeda36dc | 352 | * \fn eval(const XprMatrix<E1, Rows, Cols>& e1, const XprMatrix<E2, Rows, Cols>& e2, const std::complex<T>& x3) |
madcowswe | 15:9c5aaeda36dc | 353 | * \brief Evals the matrix expressions. |
madcowswe | 15:9c5aaeda36dc | 354 | * \ingroup _trinary_function |
madcowswe | 15:9c5aaeda36dc | 355 | * This eval is for the a?b:c syntax, since it's not allowed to overload |
madcowswe | 15:9c5aaeda36dc | 356 | * these operators. |
madcowswe | 15:9c5aaeda36dc | 357 | */ |
madcowswe | 15:9c5aaeda36dc | 358 | template<class E1, class E2, std::size_t Rows, std::size_t Cols, class T> |
madcowswe | 15:9c5aaeda36dc | 359 | inline |
madcowswe | 15:9c5aaeda36dc | 360 | XprMatrix< |
madcowswe | 15:9c5aaeda36dc | 361 | XprEval< |
madcowswe | 15:9c5aaeda36dc | 362 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 363 | XprMatrix<E2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 364 | XprLiteral< std::complex<T> > |
madcowswe | 15:9c5aaeda36dc | 365 | >, |
madcowswe | 15:9c5aaeda36dc | 366 | Rows, Cols |
madcowswe | 15:9c5aaeda36dc | 367 | > |
madcowswe | 15:9c5aaeda36dc | 368 | eval(const XprMatrix<E1, Rows, Cols>& e1, const XprMatrix<E2, Rows, Cols>& e2, const std::complex<T>& x3) { |
madcowswe | 15:9c5aaeda36dc | 369 | typedef XprEval< |
madcowswe | 15:9c5aaeda36dc | 370 | XprMatrix<E1, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 371 | XprMatrix<E2, Rows, Cols>, |
madcowswe | 15:9c5aaeda36dc | 372 | XprLiteral< std::complex<T> > |
madcowswe | 15:9c5aaeda36dc | 373 | > expr_type; |
madcowswe | 15:9c5aaeda36dc | 374 | return XprMatrix<expr_type, Rows, Cols>( |
madcowswe | 15:9c5aaeda36dc | 375 | expr_type(e1, e2, XprLiteral< std::complex<T> >(x3))); |
madcowswe | 15:9c5aaeda36dc | 376 | } |
madcowswe | 15:9c5aaeda36dc | 377 | #endif // defined(TVMET_HAVE_COMPLEX) |
madcowswe | 15:9c5aaeda36dc | 378 | |
madcowswe | 15:9c5aaeda36dc | 379 | |
madcowswe | 15:9c5aaeda36dc | 380 | } // namespace tvmet |
madcowswe | 15:9c5aaeda36dc | 381 | |
madcowswe | 15:9c5aaeda36dc | 382 | #endif // TVMET_MATRIX_EVAL_H |
madcowswe | 15:9c5aaeda36dc | 383 | |
madcowswe | 15:9c5aaeda36dc | 384 | // Local Variables: |
madcowswe | 15:9c5aaeda36dc | 385 | // mode:C++ |
madcowswe | 15:9c5aaeda36dc | 386 | // tab-width:8 |
madcowswe | 15:9c5aaeda36dc | 387 | // End: |