/* * 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: MatrixEval.h,v 1.14 2004/06/10 16:36:55 opetzold Exp $ */ #ifndef TVMET_MATRIX_EVAL_H #define TVMET_MATRIX_EVAL_H namespace tvmet { /** * \fn bool all_elements(const XprMatrix& e) * \brief check on statements for all elements * \ingroup _unary_function * This is for use with boolean operators like * \par Example: * \code * all_elements(matrix > 0) { * // true branch * } else { * // false branch * } * \endcode * \sa \ref compare */ template inline bool all_elements(const XprMatrix& e) { return meta::Matrix::all_elements(e); } /** * \fn bool any_elements(const XprMatrix& e) * \brief check on statements for any elements * \ingroup _unary_function * This is for use with boolean operators like * \par Example: * \code * any_elements(matrix > 0) { * // true branch * } else { * // false branch * } * \endcode * \sa \ref compare */ template inline bool any_elements(const XprMatrix& e) { return meta::Matrix::any_elements(e); } /* * trinary evaluation functions with matrizes and xpr of * * XprMatrix ? Matrix : Matrix * XprMatrix ? Matrix : XprMatrix * XprMatrix ? XprMatrix : Matrix * XprMatrix ? XprMatrix : XprMatrix */ /** * \fn eval(const XprMatrix& e1, const Matrix& m2, const Matrix& m3) * \brief Evals the matrix expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprMatrix< XprEval< XprMatrix, MatrixConstReference, MatrixConstReference >, Rows, Cols > eval(const XprMatrix& e1, const Matrix& m2, const Matrix& m3) { typedef XprEval< XprMatrix, MatrixConstReference, MatrixConstReference > expr_type; return XprMatrix( expr_type(e1, m2.const_ref(), m3.const_ref())); } /** * \fn eval(const XprMatrix& e1, const Matrix& m2, const XprMatrix& e3) * \brief Evals the matrix expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprMatrix< XprEval< XprMatrix, MatrixConstReference, XprMatrix >, Rows, Cols > eval(const XprMatrix& e1, const Matrix& m2, const XprMatrix& e3) { typedef XprEval< XprMatrix, MatrixConstReference, XprMatrix > expr_type; return XprMatrix( expr_type(e1, m2.const_ref(), e3)); } /** * \fn eval(const XprMatrix& e1, const XprMatrix& e2, const Matrix& m3) * \brief Evals the matrix expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprMatrix< XprEval< XprMatrix, XprMatrix, MatrixConstReference >, Rows, Cols > eval(const XprMatrix& e1, const XprMatrix& e2, const Matrix& m3) { typedef XprEval< XprMatrix, XprMatrix, MatrixConstReference > expr_type; return XprMatrix( expr_type(e1, e2, m3.const_ref())); } /** * \fn eval(const XprMatrix& e1, const XprMatrix& e2, const XprMatrix& e3) * \brief Evals the matrix expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprMatrix< XprEval< XprMatrix, XprMatrix, XprMatrix >, Rows, Cols > eval(const XprMatrix& e1, const XprMatrix& e2, const XprMatrix& e3) { typedef XprEval< XprMatrix, XprMatrix, XprMatrix > expr_type; return XprMatrix(expr_type(e1, e2, e3)); } /* * trinary evaluation functions with matrizes, xpr of and POD * * XprMatrix ? POD1 : POD2 * XprMatrix ? POD : XprMatrix * XprMatrix ? XprMatrix : POD */ #define TVMET_IMPLEMENT_MACRO(POD) \ template \ inline \ XprMatrix< \ XprEval< \ XprMatrix, \ XprLiteral< POD >, \ XprLiteral< POD > \ >, \ Rows, Cols \ > \ eval(const XprMatrix& e, POD x2, POD x3) { \ typedef XprEval< \ XprMatrix, \ XprLiteral< POD >, \ XprLiteral< POD > \ > expr_type; \ return XprMatrix( \ expr_type(e, XprLiteral< POD >(x2), XprLiteral< POD >(x3))); \ } \ \ template \ inline \ XprMatrix< \ XprEval< \ XprMatrix, \ XprLiteral< POD >, \ XprMatrix \ >, \ Rows, Cols \ > \ eval(const XprMatrix& e1, POD x2, const XprMatrix& e3) { \ typedef XprEval< \ XprMatrix, \ XprLiteral< POD >, \ XprMatrix \ > expr_type; \ return XprMatrix( \ expr_type(e1, XprLiteral< POD >(x2), e3)); \ } \ \ template \ inline \ XprMatrix< \ XprEval< \ XprMatrix, \ XprMatrix, \ XprLiteral< POD > \ >, \ Rows, Cols \ > \ eval(const XprMatrix& e1, const XprMatrix& e2, POD x3) { \ typedef XprEval< \ XprMatrix, \ XprMatrix, \ XprLiteral< POD > \ > expr_type; \ return XprMatrix( \ expr_type(e1, e2, XprLiteral< POD >(x3))); \ } TVMET_IMPLEMENT_MACRO(int) #if defined(TVMET_HAVE_LONG_LONG) TVMET_IMPLEMENT_MACRO(long long int) #endif TVMET_IMPLEMENT_MACRO(float) TVMET_IMPLEMENT_MACRO(double) #if defined(TVMET_HAVE_LONG_DOUBLE) TVMET_IMPLEMENT_MACRO(long double) #endif #undef TVMET_IMPLEMENT_MACRO /* * trinary evaluation functions with matrizes, xpr of and complex<> types * * XprMatrix e, std::complex z2, std::complex z3 * XprMatrix e1, std::complex z2, XprMatrix e3 * XprMatrix e1, XprMatrix e2, std::complex z3 */ #if defined(TVMET_HAVE_COMPLEX) /** * \fn eval(const XprMatrix& e, const std::complex& x2, const std::complex& x3) * \brief Evals the matrix expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprMatrix< XprEval< XprMatrix, XprLiteral< std::complex >, XprLiteral< std::complex > >, Rows, Cols > eval(const XprMatrix& e, const std::complex& x2, const std::complex& x3) { typedef XprEval< XprMatrix, XprLiteral< std::complex >, XprLiteral< std::complex > > expr_type; return XprMatrix( expr_type(e, XprLiteral< std::complex >(x2), XprLiteral< std::complex >(x3))); } /** * \fn eval(const XprMatrix& e1, const std::complex& x2, const XprMatrix& e3) * \brief Evals the matrix expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprMatrix< XprEval< XprMatrix, XprLiteral< std::complex >, XprMatrix >, Rows, Cols > eval(const XprMatrix& e1, const std::complex& x2, const XprMatrix& e3) { typedef XprEval< XprMatrix, XprLiteral< std::complex >, XprMatrix > expr_type; return XprMatrix( expr_type(e1, XprLiteral< std::complex >(x2), e3)); } /** * \fn eval(const XprMatrix& e1, const XprMatrix& e2, const std::complex& x3) * \brief Evals the matrix expressions. * \ingroup _trinary_function * This eval is for the a?b:c syntax, since it's not allowed to overload * these operators. */ template inline XprMatrix< XprEval< XprMatrix, XprMatrix, XprLiteral< std::complex > >, Rows, Cols > eval(const XprMatrix& e1, const XprMatrix& e2, const std::complex& x3) { typedef XprEval< XprMatrix, XprMatrix, XprLiteral< std::complex > > expr_type; return XprMatrix( expr_type(e1, e2, XprLiteral< std::complex >(x3))); } #endif // defined(TVMET_HAVE_COMPLEX) } // namespace tvmet #endif // TVMET_MATRIX_EVAL_H // Local Variables: // mode:C++ // End: