/* * Tiny Vector Matrix Library * Dense Vector Matrix Libary of Tiny size using Expression Templates * * Copyright (C) 2001 - 2003 Olaf Petzold * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: VectorEval.h,v 1.14 2003/11/30 08:26:25 opetzold Exp $ */ #ifndef TVMET_VECTOR_EVAL_H #define TVMET_VECTOR_EVAL_H namespace tvmet { /******************************************************************** * functions all_elements/any_elements ********************************************************************/ /** * \fn bool all_elements(const XprVector& e) * \brief check on statements for all elements * \ingroup _unary_function * This is for use with boolean operators like * \par Example: * \code * all_elements(vector > 0) { * // true branch * } else { * // false branch * } * \endcode * \sa \ref compare */ template inline bool all_elements(const XprVector& e) { return meta::Vector::all_elements(e); } /** * \fn bool any_elements(const XprVector& e) * \brief check on statements for any elements * \ingroup _unary_function * This is for use with boolean operators like * \par Example: * \code * any_elements(vector > 0) { * // true branch * } else { * // false branch * } * \endcode * \sa \ref compare */ template inline bool any_elements(const XprVector& e) { return meta::Vector::any_elements(e); } /* * trinary evaluation functions with vectors and xpr of * XprVector ? Vector : Vector * XprVector ? Vector : XprVector * XprVector ? XprVector : Vector * XprVector ? XprVector : XprVector */ /** * eval(const XprVector& e1, const Vector& v2, const Vector& v3) * \brief Evals the vector expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprVector< XprEval< XprVector, VectorConstReference, VectorConstReference >, Sz > eval(const XprVector& e1, const Vector& v2, const Vector& v3) { typedef XprEval< XprVector, VectorConstReference, VectorConstReference > expr_type; return XprVector( expr_type(e1, v2.const_ref(), v3.const_ref())); } /** * eval(const XprVector& e1, const Vector& v2, const XprVector& e3) * \brief Evals the vector expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprVector< XprEval< XprVector, VectorConstReference, XprVector >, Sz > eval(const XprVector& e1, const Vector& v2, const XprVector& e3) { typedef XprEval< XprVector, VectorConstReference, XprVector > expr_type; return XprVector( expr_type(e1, v2.const_ref(), e3)); } /** * eval(const XprVector& e1, const XprVector& e2, const Vector& v3) * \brief Evals the vector expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprVector< XprEval< XprVector, XprVector, VectorConstReference >, Sz > eval(const XprVector& e1, const XprVector& e2, const Vector& v3) { typedef XprEval< XprVector, XprVector, VectorConstReference > expr_type; return XprVector( expr_type(e1, e2, v3.const_ref())); } /** * eval(const XprVector& e1, const XprVector& e2, const XprVector& e3) * \brief Evals the vector expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprVector< XprEval< XprVector, XprVector, XprVector >, Sz > eval(const XprVector& e1, const XprVector& e2, const XprVector& e3) { typedef XprEval< XprVector, XprVector, XprVector > expr_type; return XprVector(expr_type(e1, e2, e3)); } /* * trinary evaluation functions with vectors, xpr of and POD * * XprVector ? POD1 : POD2 * XprVector ? POD : XprVector * XprVector ? XprVector : POD */ #define TVMET_IMPLEMENT_MACRO(POD) \ template \ inline \ XprVector< \ XprEval< \ XprVector, \ XprLiteral< POD >, \ XprLiteral< POD > \ >, \ Sz \ > \ eval(const XprVector& e, POD x2, POD x3) { \ typedef XprEval< \ XprVector, \ XprLiteral< POD >, \ XprLiteral< POD > \ > expr_type; \ return XprVector( \ expr_type(e, XprLiteral< POD >(x2), XprLiteral< POD >(x3))); \ } \ \ template \ inline \ XprVector< \ XprEval< \ XprVector, \ XprLiteral< POD >, \ XprVector \ >, \ Sz \ > \ eval(const XprVector& e1, POD x2, const XprVector& e3) { \ typedef XprEval< \ XprVector, \ XprLiteral< POD >, \ XprVector \ > expr_type; \ return XprVector( \ expr_type(e1, XprLiteral< POD >(x2), e3)); \ } \ \ template \ inline \ XprVector< \ XprEval< \ XprVector, \ XprVector, \ XprLiteral< POD > \ >, \ Sz \ > \ eval(const XprVector& e1, const XprVector& e2, POD x3) { \ typedef XprEval< \ XprVector, \ XprVector, \ XprLiteral< POD > \ > expr_type; \ return XprVector( \ expr_type(e1, e2, XprLiteral< POD >(x3))); \ } TVMET_IMPLEMENT_MACRO(int) #if defined(TVMET_HAVE_LONG_LONG) TVMET_IMPLEMENT_MACRO(long long int) #endif // defined(TVMET_HAVE_LONG_LONG) TVMET_IMPLEMENT_MACRO(float) TVMET_IMPLEMENT_MACRO(double) #if defined(TVMET_HAVE_LONG_DOUBLE) TVMET_IMPLEMENT_MACRO(long double) #endif // defined(TVMET_HAVE_LONG_DOUBLE) #undef TVMET_IMPLEMENT_MACRO /* * trinary evaluation functions with vectors, xpr of and complex<> types * * XprVector e, std::complex z2, std::complex z3 * XprVector e1, std::complex z2, XprVector e3 * XprVector e1, XprVector e2, std::complex z3 */ #if defined(TVMET_HAVE_COMPLEX) /** * eval(const XprVector& e, std::complex z2, std::complex z3) * \brief Evals the vector expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprVector< XprEval< XprVector, XprLiteral< std::complex >, XprLiteral< std::complex > >, Sz > eval(const XprVector& e, std::complex z2, std::complex z3) { typedef XprEval< XprVector, XprLiteral< std::complex >, XprLiteral< std::complex > > expr_type; return XprVector( expr_type(e, XprLiteral< std::complex >(z2), XprLiteral< std::complex >(z3))); } /** * eval(const XprVector& e1, std::complex z2, const XprVector& e3) * \brief Evals the vector expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprVector< XprEval< XprVector, XprLiteral< std::complex >, XprVector >, Sz > eval(const XprVector& e1, std::complex z2, const XprVector& e3) { typedef XprEval< XprVector, XprLiteral< std::complex >, XprVector > expr_type; return XprVector( expr_type(e1, XprLiteral< std::complex >(z2), e3)); } /** * eval(const XprVector& e1, const XprVector& e2, std::complex z3) * \brief Evals the vector expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprVector< XprEval< XprVector, XprVector, XprLiteral< std::complex > >, Sz > eval(const XprVector& e1, const XprVector& e2, std::complex z3) { typedef XprEval< XprVector, XprVector, XprLiteral< std::complex > > expr_type; return XprVector( expr_type(e1, e2, XprLiteral< std::complex >(z3))); } #endif // defined(TVMET_HAVE_COMPLEX) } // namespace tvmet #endif // TVMET_VECTOR_EVAL_H // Local Variables: // mode:C++ // End: