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