diff options
Diffstat (limited to 'tvmet-1.7.1/include/tvmet/xpr')
23 files changed, 0 insertions, 4272 deletions
diff --git a/tvmet-1.7.1/include/tvmet/xpr/BinOperator.h b/tvmet-1.7.1/include/tvmet/xpr/BinOperator.h deleted file mode 100644 index 11ade5eb3..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/BinOperator.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: BinOperator.h,v 1.15 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_BINOPERATOR_H -#define TVMET_XPR_BINOPERATOR_H - -#include <tvmet/TypePromotion.h> - -namespace tvmet { - - -/** - * \class XprBinOp BinOperator.h "tvmet/xpr/BinOperator.h" - * \brief Binary operators working on two sub expressions. - * - * On acessing using the index operator() the binary operation will be - * evaluated at compile time. - */ -template<class BinOp, class E1, class E2> -class XprBinOp - : public TvmetBase< XprBinOp<BinOp, E1, E2> > -{ - XprBinOp(); - XprBinOp& operator=(const XprBinOp&); - -public: - typedef typename BinOp::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_lhs = E1::ops, - ops_rhs = E2::ops, - ops = 2 * (ops_lhs + ops_rhs) // lhs op rhs - }; - -public: - /** Constructor for two expressions. */ - explicit XprBinOp(const E1& lhs, const E2& rhs) - : m_lhs(lhs), m_rhs(rhs) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprBinOp(const XprBinOp& e) - : m_lhs(e.m_lhs), m_rhs(e.m_rhs) - { } -#endif - - /** Index operator, evaluates the expression inside. */ - value_type operator()(int i) const { - return BinOp::apply_on(m_lhs(i), m_rhs(i)); - } - - /** Index operator for arrays/matrices */ - value_type operator()(int i, int j) const { - return BinOp::apply_on(m_lhs(i, j), m_rhs(i, j)); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprBinOp[O="<< ops << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<" - << std::endl; - BinOp::print_xpr(os, l); - m_lhs.print_xpr(os, l); - m_rhs.print_xpr(os, l); - os << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E1 m_lhs; - const E2 m_rhs; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_BINOPERATOR_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/CMakeLists.txt b/tvmet-1.7.1/include/tvmet/xpr/CMakeLists.txt deleted file mode 100644 index 06cf78c0c..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -FILE(GLOB tvmet_xpr_header_SRCS "*.h") - -INSTALL(FILES - ${tvmet_xpr_header_SRCS} - DESTINATION ${INCLUDE_INSTALL_DIR}/xpr - ) diff --git a/tvmet-1.7.1/include/tvmet/xpr/Eval.h b/tvmet-1.7.1/include/tvmet/xpr/Eval.h deleted file mode 100644 index 7ed92161b..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/Eval.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: Eval.h,v 1.9 2003/11/30 18:35:17 opetzold Exp $ - */ - -#ifndef TVMET_XPR_EVAL_H -#define TVMET_XPR_EVAL_H - -namespace tvmet { - - -/** - * \class XprEval Eval.h "tvmet/xpr/Eval.h" - * \brief evaluate the expression - * - * Since we can't overwrite the ? operator we have to write a wrapper - * for expression like return v1>v2 ? true : false - */ -template<class E1, class E2, class E3> -class XprEval - : public TvmetBase< XprEval<E1, E2, E3> > -{ -public: - typedef E1 expr1_type; - typedef E2 expr2_type; - typedef E3 expr3_type; - - typedef typename expr2_type::value_type value2_type; - typedef typename expr3_type::value_type value3_type; - - typedef typename - PromoteTraits<value2_type, value3_type>::value_type value_type; - -public: - /** Complexity Counter */ - enum { - ops_expr1 = E1::ops, - ops_expr2 = E2::ops, - ops_expr3 = E3::ops, - ops = ops_expr1 // only (e1 op e2) are evaluated - }; - -private: - XprEval(); - XprEval& operator=(const XprEval<expr1_type, expr2_type, expr3_type>&); - -public: - /** Constructor */ - explicit XprEval(const expr1_type& e1, const expr2_type& e2, const expr3_type& e3) - : m_expr1(e1), m_expr2(e2), m_expr3(e3) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprEval(const XprEval& rhs) - : m_expr1(rhs.m_expr1), m_expr2(rhs.m_expr2), m_expr3(rhs.m_expr3) - { } -#endif - -public: //access - /** index operator for vectors. */ - value_type operator()(int i) const { - return m_expr1(i) ? m_expr2(i) : m_expr3(i); - } - - /** index operator for matrizes. */ - value_type operator()(int i, int j) const { - return m_expr1(i, j) ? m_expr2(i, j) : m_expr3(i, j); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprEval[" << ops << ", (" - << ops_expr1 << ", " << ops_expr2 << ", " << ops_expr3 << ")]<" - << std::endl; - m_expr1.print_xpr(os, l); - m_expr2.print_xpr(os, l); - m_expr3.print_xpr(os, l); - os << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const expr1_type m_expr1; - const expr2_type m_expr2; - const expr3_type m_expr3; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_EVAL_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/Identity.h b/tvmet-1.7.1/include/tvmet/xpr/Identity.h deleted file mode 100644 index 7b13fa6b6..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/Identity.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * $Id: Identity.h,v 1.3 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_IDENTITY_H -#define TVMET_XPR_IDENTITY_H - - -namespace tvmet { - - -/** - * \class XprIdentity Identity.h "tvmet/xpr/Identity.h" - * \brief Expression for the identity matrix. - * - * This expression doesn't hold any other expression, it - * simply returns 1 or 0 depends where the row and column - * element excess is done. - * - * \since release 1.6.0 - * \sa identity - */ -template<class T, int Rows, int Cols> -struct XprIdentity - : public TvmetBase< XprIdentity<T, Rows, Cols> > -{ - XprIdentity& operator=(const XprIdentity&); - -public: - typedef T value_type; - -public: - /** Complexity counter. */ - enum { - ops_assign = Rows * Cols, - ops = ops_assign - }; - -public: - /** access by index. */ - value_type operator()(int i, int j) const { - return i==j ? 1 : 0; - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprIdentity[O="<< ops << ")]<" - << std::endl; - os << IndentLevel(l) - << typeid(T).name() << "," - << "R=" << Rows << ", C=" << Cols << std::endl; - os << IndentLevel(--l) << ">" - << ((l != 0) ? "," : "") << std::endl; - } -}; - - -} // namespace tvmet - - -#endif // TVMET_XPR_IDENTITY_H - - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/Literal.h b/tvmet-1.7.1/include/tvmet/xpr/Literal.h deleted file mode 100644 index 85d9c79c0..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/Literal.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: Literal.h,v 1.9 2003/11/30 18:35:17 opetzold Exp $ - */ - -#ifndef TVMET_XPR_LITERAL_H -#define TVMET_XPR_LITERAL_H - -namespace tvmet { - - -/** - * \class XprLiteral Literal.h "tvmet/xpr/Literal.h" - * \brief Specify literals like scalars into the expression. - * This expression is used for vectors and matrices - the - * decision is done by the access operator. - */ -template<class T> -class XprLiteral - : public TvmetBase< XprLiteral<T> > -{ - XprLiteral(); - XprLiteral& operator=(const XprLiteral&); - -public: - typedef T value_type; - -public: - /** Complexity counter. */ - enum { - ops = 1 - }; - -public: - /** Constructor by value for literals . */ - explicit XprLiteral(value_type value) - : m_data(value) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprLiteral(const XprLiteral& e) - : m_data(e.m_data) - { } -#endif - - /** Index operator, gives the value for vectors. */ - value_type operator()(int) const { return m_data; } - - /** Index operator for arrays/matrices. */ - value_type operator()(int, int) const { return m_data; } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) << "XprLiteral[O=" << ops << "]<T=" - << typeid(value_type).name() - << ">," << std::endl; - } - -private: - const value_type m_data; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_LITERAL_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MMProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MMProduct.h deleted file mode 100644 index 0d165ea8c..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MMProduct.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MMProduct.h,v 1.20 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MMPRODUCT_H -#define TVMET_XPR_MMPRODUCT_H - -#include <cassert> - -#include <tvmet/meta/Gemm.h> -#include <tvmet/loop/Gemm.h> - -namespace tvmet { - - -/** - * \class XprMMProduct MMProduct.h "tvmet/xpr/MMProduct.h" - * \brief Expression for matrix-matrix product. - * Using formula: - * \f[ - * M_1\,M_2 - * \f] - * \note The Rows2 has to be equal to Cols1. - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -class XprMMProduct - : public TvmetBase< XprMMProduct<E1, Rows1, Cols1, E2, Cols2> > -{ -private: - XprMMProduct(); - XprMMProduct& operator=(const XprMMProduct&); - -public: - typedef typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_lhs = E1::ops, - ops_rhs = E2::ops, - M = Rows1 * Cols1 * Cols2, - N = Rows1 * (Cols1 - 1) * Cols2, - ops_plus = M * Traits<value_type>::ops_plus, - ops_muls = N * Traits<value_type>::ops_muls, - ops = ops_plus + ops_muls, - use_meta = Rows1*Cols2 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false - }; - -public: - /** Constructor. */ - explicit XprMMProduct(const E1& lhs, const E2& rhs) - : m_lhs(lhs), m_rhs(rhs) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMMProduct(const XprMMProduct& e) - : m_lhs(e.m_lhs), m_rhs(e.m_rhs) - { } -#endif - -private: - /** Wrapper for meta gemm. */ - static inline - value_type do_gemm(dispatch<true>, const E1& lhs, const E2& rhs, int i, int j) { - return meta::gemm<Rows1, Cols1, - Cols2, - 0>::prod(lhs, rhs, i, j); - } - - /** Wrapper for loop gemm. */ - static inline - value_type do_gemm(dispatch<false>, const E1& lhs, const E2& rhs, int i, int j) { - return loop::gemm<Rows1, Cols1, Cols2>::prod(lhs, rhs, i, j); - } - -public: - /** index operator for arrays/matrices */ - value_type operator()(int i, int j) const { - assert((i < Rows1) && (j < Cols2)); - return do_gemm(dispatch<use_meta>(), m_lhs, m_rhs, i, j); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMMProduct[" - << (use_meta ? "M" : "L") << ", O=" << ops - << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<" - << std::endl; - m_lhs.print_xpr(os, l); - os << IndentLevel(l) - << "R1=" << Rows1 << ", C1=" << Cols1 << ",\n"; - m_rhs.print_xpr(os, l); - os << IndentLevel(l) - << "C2=" << Cols2 << ",\n"; - os << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E1 m_lhs; - const E2 m_rhs; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MMPRODUCT_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h b/tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h deleted file mode 100644 index d869e3af8..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MMProductTransposed.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MMProductTransposed.h,v 1.16 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MMPRODUCT_TRANSPOSED_H -#define TVMET_XPR_MMPRODUCT_TRANSPOSED_H - -#include <cassert> - -#include <tvmet/meta/Gemm.h> -#include <tvmet/loop/Gemm.h> - -namespace tvmet { - - -/** - * \class XprMMProductTransposed MMProductTransposed.h "tvmet/xpr/MMProductTransposed.h" - * \brief Expression for transpose(matrix-matrix product). - * Using formula: - * \f[ - * (M_1\,M_2)^T - * \f] - * \note The Rows2 has to be equal to Cols1. - * The result is a (Cols2 x Rows1) matrix. - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -class XprMMProductTransposed - : public TvmetBase< XprMMProductTransposed<E1, Rows1, Cols1, E2, Cols2> > -{ -private: - XprMMProductTransposed(); - XprMMProductTransposed& operator=(const XprMMProductTransposed&); - -public: - typedef typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_lhs = E1::ops, - ops_rhs = E2::ops, - M = Rows1 * Cols1 * Cols2, - N = Rows1 * (Cols1-1) * Cols2, - ops_plus = M * Traits<value_type>::ops_plus, - ops_muls = N * Traits<value_type>::ops_muls, - ops = ops_plus + ops_muls, - use_meta = Cols2*Rows1 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false - }; - -public: - /** Constructor. */ - explicit XprMMProductTransposed(const E1& lhs, const E2& rhs) - : m_lhs(lhs), m_rhs(rhs) { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMMProductTransposed(const XprMMProductTransposed& e) - : m_lhs(e.m_lhs), m_rhs(e.m_rhs) - { } -#endif - -private: - /** Wrapper for meta gemm. */ - static inline - value_type do_gemm(dispatch<true>, const E1& lhs, const E2& rhs, int i, int j) { - return meta::gemm<Rows1, Cols1, - Cols2, - 0>::prod(lhs, rhs, i, j); - } - - /** Wrapper for loop gemm. */ - static inline - value_type do_gemm(dispatch<false>, const E1& lhs, const E2& rhs, int i, int j) { - return loop::gemm<Rows1, Cols1, Cols2>::prod(lhs, rhs, i, j); - } - -public: - /** index operator for arrays/matrices */ - value_type operator()(int i, int j) const { - assert((i < Cols2) && (j < Rows1)); - return do_gemm(dispatch<use_meta>(), m_lhs, m_rhs, j, i); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMMProductTransposed[" - << (use_meta ? "M" : "L") << ", O=" << ops - << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<" - << std::endl; - m_lhs.print_xpr(os, l); - os << IndentLevel(l) - << "R1=" << Rows1 << ", C1=" << Cols1 << ",\n"; - m_rhs.print_xpr(os, l); - os << IndentLevel(l) - << "C2=" << Cols2 << ",\n" - << IndentLevel(l) - << "\n" - << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E1 m_lhs; - const E2 m_rhs; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MMPRODUCT_TRANSPOSED_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h deleted file mode 100644 index 71c6dda63..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MMtProduct.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MMtProduct.h,v 1.16 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MMTPRODUCT_H -#define TVMET_XPR_MMTPRODUCT_H - -#include <cassert> - -#include <tvmet/meta/Gemmt.h> -#include <tvmet/loop/Gemmt.h> - -namespace tvmet { - - -/** - * \class XprMMtProduct MMtProduct.h "tvmet/xpr/MMtProduct.h" - * \brief Expression for matrix-matrix product. - * Using formula: - * \f[ - * M_1\,M_2^T - * \f] - * \note The number of cols of rhs matrix have to be equal to cols of rhs matrix. - * The result is a (Rows1 x Rows2) matrix. - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -class XprMMtProduct - : public TvmetBase< XprMMtProduct<E1, Rows1, Cols1, E2, Cols2> > -{ -private: - XprMMtProduct(); - XprMMtProduct& operator=(const XprMMtProduct&); - -public: - typedef typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_lhs = E1::ops, - ops_rhs = E2::ops, - Rows2 = Cols1, - M = Rows1 * Cols1 * Rows1, - N = Rows1 * (Cols1 - 1) * Rows2, - ops_plus = M * Traits<value_type>::ops_plus, - ops_muls = N * Traits<value_type>::ops_muls, - ops = ops_plus + ops_muls, - use_meta = Rows1*Rows2 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false - }; - -public: - /** Constructor. */ - explicit XprMMtProduct(const E1& lhs, const E2& rhs) - : m_lhs(lhs), m_rhs(rhs) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMMtProduct(const XprMMtProduct& e) - : m_lhs(e.m_lhs), m_rhs(e.m_rhs) - { } -#endif - -private: - /** Wrapper for meta gemm. */ - static inline - value_type do_gemmt(dispatch<true>, const E1& lhs, const E2& rhs, int i, int j) { - return meta::gemmt<Rows1, Cols1, - Cols2, - 0>::prod(lhs, rhs, i, j); - } - - /** Wrapper for loop gemm. */ - static inline - value_type do_gemmt(dispatch<false>, const E1& lhs, const E2& rhs, int i, int j) { - return loop::gemmt<Rows1, Cols1, Cols1>::prod(lhs, rhs, i, j); - } - -public: - /** index operator for arrays/matrices */ - value_type operator()(int i, int j) const { - assert((i < Rows1) && (j < Rows2)); - return do_gemmt(dispatch<use_meta>(), m_lhs, m_rhs, i, j); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMMtProduct[" - << (use_meta ? "M" : "L") << ", O=" << ops - << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<" - << std::endl; - m_lhs.print_xpr(os, l); - os << IndentLevel(l) - << "R1=" << Rows1 << ", C1=" << Cols1 << ",\n"; - m_rhs.print_xpr(os, l); - os << IndentLevel(l) - << "C2=" << Cols2 << ",\n" - << "\n" - << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E1 m_lhs; - const E2 m_rhs; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MMTPRODUCT_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MVProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MVProduct.h deleted file mode 100644 index 0b9202f15..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MVProduct.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MVProduct.h,v 1.17 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MVPRODUCT_H -#define TVMET_XPR_MVPRODUCT_H - -#include <cassert> - -#include <tvmet/meta/Gemv.h> -#include <tvmet/loop/Gemv.h> - -namespace tvmet { - - -/** - * \class XprMVProduct MVProduct.h "tvmet/xpr/MVProduct.h" - * \brief Expression for matrix-vector product - * using formula - * \f[ - * M\,v - * \f] - */ -template<class E1, int Rows, int Cols, - class E2> -class XprMVProduct - : public TvmetBase< XprMVProduct<E1, Rows, Cols, E2> > -{ - XprMVProduct(); - XprMVProduct& operator=(const XprMVProduct&); - -public: - typedef typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_lhs = E1::ops, - ops_rhs = E2::ops, - M = Rows * Cols, - N = Rows * (Cols - 1), - ops_plus = M * Traits<value_type>::ops_plus, - ops_muls = N * Traits<value_type>::ops_muls, - ops = ops_plus + ops_muls, - use_meta = Rows*Cols < TVMET_COMPLEXITY_MV_TRIGGER ? true : false - }; - -public: - /** Constructor. */ - explicit XprMVProduct(const E1& lhs, const E2& rhs) - : m_lhs(lhs), m_rhs(rhs) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMVProduct(const XprMVProduct& e) - : m_lhs(e.m_lhs), m_rhs(e.m_rhs) - { } -#endif - -private: - /** Wrapper for meta gemm. */ - static inline - value_type do_gemv(dispatch<true>, const E1& lhs, const E2& rhs, int j) { - return meta::gemv<Rows, Cols, - 0>::prod(lhs, rhs, j); - } - - /** Wrapper for loop gemm. */ - static inline - value_type do_gemv(dispatch<false>, const E1& lhs, const E2& rhs, int j) { - return loop::gemv<Rows, Cols>::prod(lhs, rhs, j); - } - -public: - /** index operator, returns the expression by index. This is the vector - style since a matrix*vector gives a vector. */ - value_type operator()(int j) const { - assert(j < Rows); - return do_gemv(dispatch<use_meta>(), m_lhs, m_rhs, j); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMVProduct[" - << (use_meta ? "M" : "L") << ", O=" << ops - << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<" - << std::endl; - m_lhs.print_xpr(os, l); - os << IndentLevel(l) - << "R=" << Rows << ", C=" << Cols << ",\n"; - m_rhs.print_xpr(os, l); - os << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E1 m_lhs; - const E2 m_rhs; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MVPRODUCT_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/Matrix.h b/tvmet-1.7.1/include/tvmet/xpr/Matrix.h deleted file mode 100644 index d10176f89..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/Matrix.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: Matrix.h,v 1.22 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MATRIX_H -#define TVMET_XPR_MATRIX_H - -#include <cassert> - -#include <tvmet/meta/Matrix.h> -#include <tvmet/loop/Matrix.h> - -namespace tvmet { - - -/* forwards */ -template <class T, int Rows, int Cols> class Matrix; - -/** - * \class XprMatrix Matrix.h "tvmet/xpr/Matrix.h" - * \brief Represents the expression for vectors at any node in the parse tree. - * - * Specifically, XprMatrix is the class that wraps the expression, and the - * expression itself is represented by the template parameter E. The - * class XprMatrix is known as an anonymizing expression wrapper because - * it can hold any subexpression of arbitrary complexity, allowing - * clients to work with any expression by holding on to it via the - * wrapper, without having to know the name of the type object that - * actually implements the expression. - * \note leave the CCtors non-explicit to allow implicit type conversation. - */ -template<class E, int Rows, int Cols> -class XprMatrix - : public TvmetBase< XprMatrix<E, Rows, Cols> > -{ - XprMatrix(); - XprMatrix& operator=(const XprMatrix&); - -public: - /** Complexity counter. */ - enum { - ops_assign = Rows * Cols, - ops = E::ops, - use_meta = ops_assign < TVMET_COMPLEXITY_M_ASSIGN_TRIGGER ? true : false - }; - -public: - typedef typename E::value_type value_type; - -public: - /** Constructor. */ - explicit XprMatrix(const E& e) - : m_expr(e) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMatrix(const XprMatrix& rhs) - : m_expr(rhs.m_expr) - { } -#endif - - /** access by index. */ - value_type operator()(int i, int j) const { - assert((i < Rows) && (j < Cols)); - return m_expr(i, j); - } - -private: - /** Wrapper for meta assign. */ - template<class Dest, class Src, class Assign> - static inline - void do_assign(dispatch<true>, Dest& dest, const Src& src, const Assign& assign_fn) { - meta::Matrix<Rows, Cols, 0, 0>::assign(dest, src, assign_fn); - } - - /** Wrapper for loop assign. */ - template<class Dest, class Src, class Assign> - static inline - void do_assign(dispatch<false>, Dest& dest, const Src& src, const Assign& assign_fn) { - loop::Matrix<Rows, Cols>::assign(dest, src, assign_fn); - } - -public: - /** assign this expression to Matrix dest. */ - template<class Dest, class Assign> - void assign_to(Dest& dest, const Assign& assign_fn) const { - /* here is a way for caching, since each complex 'Node' - is of type XprMatrix. */ - do_assign(dispatch<use_meta>(), dest, *this, assign_fn); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMatrix[" - << (use_meta ? "M" : "L") << ", O=" << ops << "]<" - << std::endl; - m_expr.print_xpr(os, l); - os << IndentLevel(l) - << "R=" << Rows << ", C=" << Cols << std::endl; - os << IndentLevel(--l) << ">" - << ((l != 0) ? "," : "") << std::endl; - } - -private: - const E m_expr; -}; - - -} // namespace tvmet - -#include <tvmet/Functional.h> - -#include <tvmet/xpr/BinOperator.h> -#include <tvmet/xpr/UnOperator.h> -#include <tvmet/xpr/Literal.h> - -#include <tvmet/xpr/Identity.h> - -#include <tvmet/xpr/MMProduct.h> -#include <tvmet/xpr/MMProductTransposed.h> -#include <tvmet/xpr/MMtProduct.h> -#include <tvmet/xpr/MtMProduct.h> -#include <tvmet/xpr/MVProduct.h> -#include <tvmet/xpr/MtVProduct.h> -#include <tvmet/xpr/MatrixTranspose.h> - -#include <tvmet/xpr/MatrixFunctions.h> -#include <tvmet/xpr/MatrixOperators.h> -#include <tvmet/xpr/Eval.h> - -#endif // TVMET_XPR_MATRIX_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MatrixCol.h b/tvmet-1.7.1/include/tvmet/xpr/MatrixCol.h deleted file mode 100644 index 47e2554b8..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MatrixCol.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MatrixCol.h,v 1.15 2004/09/16 09:14:18 opetzold Exp $ - */ - -#include <cassert> - -#ifndef TVMET_XPR_MATRIX_COL_H -#define TVMET_XPR_MATRIX_COL_H - -namespace tvmet { - - -/** - * \class XprMatrixCol MatrixCol.h "tvmet/xpr/MatrixCol.h" - * \brief Expression on matrix used for access on the column vector. - */ -template<class E, int Rows, int Cols> -class XprMatrixCol - : public TvmetBase< XprMatrixCol<E, Rows, Cols> > -{ - XprMatrixCol(); - XprMatrixCol& operator=(const XprMatrixCol&); - -public: - typedef typename E::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_expr = E::ops, - ops = ops_expr/Cols // equal Row accesses - }; - -public: - /** Constructor. */ - explicit XprMatrixCol(const E& e, int no) - : m_expr(e), m_col(no) - { - assert(no < Cols); - } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMatrixCol(const XprMatrixCol& e) - : m_expr(e.m_expr), m_col(e.m_col) - { } -#endif - - value_type operator()(int i) const { - assert(i < Rows); - return m_expr(i, m_col); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMatrixCol[O=" << ops << ", (O=" << ops_expr << ")]<" - << std::endl; - m_expr.print_xpr(os, l); - os << IndentLevel(l) - << "R=" << Rows << ", C=" << Cols << std::endl - << IndentLevel(--l) << ">" - << ((l != 0) ? "," : "") << std::endl; - } - -private: - const E m_expr; - const int m_col; -}; - - -} - -#endif // TVMET_XPR_MATRIX_COL_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MatrixDiag.h b/tvmet-1.7.1/include/tvmet/xpr/MatrixDiag.h deleted file mode 100644 index 4a8a080ac..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MatrixDiag.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MatrixDiag.h,v 1.13 2004/09/16 09:14:18 opetzold Exp $ - */ - -#include <cassert> - -#ifndef TVMET_XPR_MATRIX_DIAG_H -#define TVMET_XPR_MATRIX_DIAG_H - -namespace tvmet { - - -/** - * \class XprMatrixDiag MatrixDiag.h "tvmet/xpr/MatrixDiag.h" - * \brief Expression on matrix used for access on the diagonal vector. - */ -template<class E, int Sz> -class XprMatrixDiag - : public TvmetBase< XprMatrixDiag<E, Sz> > -{ - XprMatrixDiag(); - XprMatrixDiag& operator=(const XprMatrixDiag<E, Sz>&); - -public: - typedef typename E::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_expr = E::ops, - ops = ops_expr/Sz - }; - -public: - /** Constructor. */ - explicit XprMatrixDiag(const E& e) - : m_expr(e) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMatrixDiag(const XprMatrixDiag& e) - : m_expr(e.m_expr) - { } -#endif - - /** index operator for arrays/matrizes */ - value_type operator()(int i) const { - assert(i < Sz); - return m_expr(i, i); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMatrixDiag[O=" << ops << ", (O=" << ops_expr << ")]<" - << std::endl; - m_expr.print_xpr(os, l); - os << IndentLevel(l) - << "Sz=" << Sz << std::endl - << IndentLevel(--l) << ">" - << ((l != 0) ? "," : "") << std::endl; - } - -private: - const E m_expr; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MATRIX_DIAG_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h b/tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h deleted file mode 100644 index 54f02c08d..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MatrixFunctions.h +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MatrixFunctions.h,v 1.39 2004/07/06 05:49:22 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MATRIX_FUNCTIONS_H -#define TVMET_XPR_MATRIX_FUNCTIONS_H - -namespace tvmet { - - -/* forwards */ -template<class T, int Rows, int Cols> class Matrix; -template<class T, int Sz> class Vector; -template<class E, int Sz> class XprVector; -template<class E> class XprMatrixTranspose; -template<class E, int Sz> class XprMatrixDiag; -template<class E, int Rows, int Cols> class XprMatrixRow; -template<class E, int Rows, int Cols> class XprMatrixCol; - - -/********************************************************* - * PART I: DECLARATION - *********************************************************/ - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Matrix arithmetic functions add, sub, mul and div - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * function(XprMatrix<E1, Rows, Cols>, XprMatrix<E2, Rows, Cols>) - */ -#define TVMET_DECLARE_MACRO(NAME) \ -template<class E1, class E2, int Rows, int Cols> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprMatrix<E1, Rows, Cols>, \ - XprMatrix<E2, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -NAME (const XprMatrix<E1, Rows, Cols>& lhs, \ - const XprMatrix<E2, Rows, Cols>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add) // per se element wise -TVMET_DECLARE_MACRO(sub) // per se element wise -namespace element_wise { - TVMET_DECLARE_MACRO(mul) // not defined for matrizes - TVMET_DECLARE_MACRO(div) // not defined for matrizes -} - -#undef TVMET_DECLARE_MACRO - - -/* - * function(XprMatrix<E, Rows, Cols>, POD) - * function(POD, XprMatrix<E, Rows, Cols>) - * Note: - operations +,-,*,/ are per se element wise - */ -#define TVMET_DECLARE_MACRO(NAME, POD) \ -template<class E, int Rows, int Cols> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, POD >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< POD > \ - >, \ - Rows, Cols \ -> \ -NAME (const XprMatrix<E, Rows, Cols>& lhs, \ - POD rhs) _tvmet_always_inline; \ - \ -template<class E, int Rows, int Cols> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -NAME (POD lhs, \ - const XprMatrix<E, Rows, Cols>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, int) -TVMET_DECLARE_MACRO(sub, int) -TVMET_DECLARE_MACRO(mul, int) -TVMET_DECLARE_MACRO(div, int) - -TVMET_DECLARE_MACRO(add, float) -TVMET_DECLARE_MACRO(sub, float) -TVMET_DECLARE_MACRO(mul, float) -TVMET_DECLARE_MACRO(div, float) - -TVMET_DECLARE_MACRO(add, double) -TVMET_DECLARE_MACRO(sub, double) -TVMET_DECLARE_MACRO(mul, double) -TVMET_DECLARE_MACRO(div, double) - -#undef TVMET_DECLARE_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * function(XprMatrix<E, Rows, Cols>, complex<T>) - * function(complex<T>, XprMatrix<E, Rows, Cols>) - * Note: - operations +,-,*,/ are per se element wise - * \todo type promotion - */ -#define TVMET_DECLARE_MACRO(NAME) \ -template<class E, class T, int Rows, int Cols> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, std::complex<T> >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< std::complex<T> > \ - >, \ - Rows, Cols \ -> \ -NAME (const XprMatrix<E, Rows, Cols>& lhs, \ - const std::complex<T>& rhs) _tvmet_always_inline; \ - \ -template<class T, class E, int Rows, int Cols> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -NAME (const std::complex<T>& lhs, \ - const XprMatrix<E, Rows, Cols>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add) -TVMET_DECLARE_MACRO(sub) -TVMET_DECLARE_MACRO(mul) -TVMET_DECLARE_MACRO(div) - -#undef TVMET_DECLARE_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix prod( ... ) functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -XprMatrix< - XprMMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Cols1, Cols2>, Cols2 - >, - Rows1, Cols2 // return Dim -> -prod(const XprMatrix<E1, Rows1, Cols1>& lhs, - const XprMatrix<E2, Cols1, Cols2>& rhs) _tvmet_always_inline; - - -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -XprMatrix< - XprMMProductTransposed< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Cols1, Cols2>, Cols2 // M2(Cols1, Cols2) - >, - Cols2, Rows1 // return Dim -> -trans_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, - const XprMatrix<E2, Cols1, Cols2>& rhs) _tvmet_always_inline; - - -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> // Rows2 = Rows1 -XprMatrix< - XprMtMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Rows1, Cols2>, Cols2 // M2(Rows1, Cols2) - >, - Cols1, Cols2 // return Dim -> -MtM_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, - const XprMatrix<E2, Rows1, Cols2>& rhs) _tvmet_always_inline; - - -template<class E1, int Rows1, int Cols1, - class E2, int Rows2> // Cols2 = Cols1 -XprMatrix< - XprMMtProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Rows2, Cols1>, Cols1 // M2(Rows2, Cols1) - >, - Rows1, Rows2 // return Dim -> -MMt_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, - const XprMatrix<E2, Rows2, Cols1>& rhs) _tvmet_always_inline; - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix-vector specific prod( ... ) functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -template<class E1, int Rows, int Cols, - class E2> -XprVector< - XprMVProduct< - XprMatrix<E1, Rows, Cols>, Rows, Cols, - XprVector<E2, Cols> - >, - Rows -> -prod(const XprMatrix<E1, Rows, Cols>& lhs, - const XprVector<E2, Cols>& rhs) _tvmet_always_inline; - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix specific functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -template<class E, int Rows, int Cols> -XprMatrix< - XprMatrixTranspose< - XprMatrix<E, Rows, Cols> - >, - Cols, Rows -> -trans(const XprMatrix<E, Rows, Cols>& rhs) _tvmet_always_inline; - - -#if 0 // XXX needs declaration of meta::Matrix<Sz, Sz, 0, 0>::trace -template<class E, int Sz> -typename Traits<typename E::value_type>::sum_type -trace(const XprMatrix<E, Sz, Sz>& m)_tvmet_always_inline; -#endif - - -template<class E, int Rows, int Cols> -XprVector< - XprMatrixRow< - XprMatrix<E, Rows, Cols>, - Rows, Cols - >, - Cols -> -row(const XprMatrix<E, Rows, Cols>& m, - int no) _tvmet_always_inline; - - -template<class E, int Rows, int Cols> -XprVector< - XprMatrixCol< - XprMatrix<E, Rows, Cols>, - Rows, Cols - >, - Rows -> -col(const XprMatrix<E, Rows, Cols>& m, int no) _tvmet_always_inline; - - -template<class E, int Sz> -XprVector< - XprMatrixDiag< - XprMatrix<E, Sz, Sz>, - Sz - >, - Sz -> -diag(const XprMatrix<E, Sz, Sz>& m) _tvmet_always_inline; - - -/********************************************************* - * PART II: IMPLEMENTATION - *********************************************************/ - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Matrix arithmetic functions add, sub, mul and div - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * function(XprMatrix<E1, Rows, Cols>, XprMatrix<E2, Rows, Cols>) - */ -#define TVMET_IMPLEMENT_MACRO(NAME) \ -template<class E1, class E2, int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprMatrix<E1, Rows, Cols>, \ - XprMatrix<E2, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -NAME (const XprMatrix<E1, Rows, Cols>& lhs, \ - const XprMatrix<E2, Rows, Cols>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprMatrix<E1, Rows, Cols>, \ - XprMatrix<E2, Rows, Cols> \ - > expr_type; \ - return XprMatrix<expr_type, Rows, Cols>(expr_type(lhs, rhs)); \ -} - -TVMET_IMPLEMENT_MACRO(add) // per se element wise -TVMET_IMPLEMENT_MACRO(sub) // per se element wise -namespace element_wise { - TVMET_IMPLEMENT_MACRO(mul) // not defined for matrizes - TVMET_IMPLEMENT_MACRO(div) // not defined for matrizes -} - -#undef TVMET_IMPLEMENT_MACRO - - -/* - * function(XprMatrix<E, Rows, Cols>, POD) - * function(POD, XprMatrix<E, Rows, Cols>) - * Note: - operations +,-,*,/ are per se element wise - */ -#define TVMET_IMPLEMENT_MACRO(NAME, POD) \ -template<class E, int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, POD >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< POD > \ - >, \ - Rows, Cols \ -> \ -NAME (const XprMatrix<E, Rows, Cols>& lhs, POD rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME<typename E::value_type, POD >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< POD > \ - > expr_type; \ - return XprMatrix<expr_type, Rows, Cols>( \ - expr_type(lhs, XprLiteral< POD >(rhs))); \ -} \ - \ -template<class E, int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -NAME (POD lhs, const XprMatrix<E, Rows, Cols>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprMatrix<E, Rows, Cols> \ - > expr_type; \ - return XprMatrix<expr_type, Rows, Cols>( \ - expr_type(XprLiteral< POD >(lhs), rhs)); \ -} - -TVMET_IMPLEMENT_MACRO(add, int) -TVMET_IMPLEMENT_MACRO(sub, int) -TVMET_IMPLEMENT_MACRO(mul, int) -TVMET_IMPLEMENT_MACRO(div, int) - -TVMET_IMPLEMENT_MACRO(add, float) -TVMET_IMPLEMENT_MACRO(sub, float) -TVMET_IMPLEMENT_MACRO(mul, float) -TVMET_IMPLEMENT_MACRO(div, float) - -TVMET_IMPLEMENT_MACRO(add, double) -TVMET_IMPLEMENT_MACRO(sub, double) -TVMET_IMPLEMENT_MACRO(mul, double) -TVMET_IMPLEMENT_MACRO(div, double) - -#undef TVMET_IMPLEMENT_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * function(XprMatrix<E, Rows, Cols>, complex<T>) - * function(complex<T>, XprMatrix<E, Rows, Cols>) - * Note: - operations +,-,*,/ are per se element wise - * \todo type promotion - */ -#define TVMET_IMPLEMENT_MACRO(NAME) \ -template<class E, class T, int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, std::complex<T> >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< std::complex<T> > \ - >, \ - Rows, Cols \ -> \ -NAME (const XprMatrix<E, Rows, Cols>& lhs, \ - const std::complex<T>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME<typename E::value_type, std::complex<T> >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< std::complex<T> > \ - > expr_type; \ - return XprMatrix<expr_type, Rows, Cols>( \ - expr_type(lhs, XprLiteral< std::complex<T> >(rhs))); \ -} \ - \ -template<class T, class E, int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -NAME (const std::complex<T>& lhs, \ - const XprMatrix<E, Rows, Cols>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprMatrix<E, Rows, Cols> \ - > expr_type; \ - return XprMatrix<expr_type, Rows, Cols>( \ - expr_type(XprLiteral< std::complex<T> >(lhs), rhs)); \ -} - -TVMET_IMPLEMENT_MACRO(add) -TVMET_IMPLEMENT_MACRO(sub) -TVMET_IMPLEMENT_MACRO(mul) -TVMET_IMPLEMENT_MACRO(div) - -#undef TVMET_IMPLEMENT_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix prod( ... ) functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) - * \brief Evaluate the product of two XprMatrix. - * Perform on given Matrix M1 and M2: - * \f[ - * M_1\,M_2 - * \f] - * \note The numer of Rows2 has to be equal to Cols1. - * \ingroup _binary_function - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -inline -XprMatrix< - XprMMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Cols1, Cols2>, Cols2 - >, - Rows1, Cols2 // return Dim -> -prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) { - typedef XprMMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, - XprMatrix<E2, Cols1, Cols2>, Cols2 - > expr_type; - return XprMatrix<expr_type, Rows1, Cols2>(expr_type(lhs, rhs)); -} - - -/** - * \fn trans_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) - * \brief Function for the trans(matrix-matrix-product) - * Perform on given Matrix M1 and M2: - * \f[ - * (M_1\,M_2)^T - * \f] - * \note The numer of Rows2 has to be equal to Cols1. - * \ingroup _binary_function - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -inline -XprMatrix< - XprMMProductTransposed< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Cols1, Cols2>, Cols2 // M2(Cols1, Cols2) - >, - Cols2, Rows1 // return Dim -> -trans_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) { - typedef XprMMProductTransposed< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, - XprMatrix<E2, Cols1, Cols2>, Cols2 - > expr_type; - return XprMatrix<expr_type, Cols2, Rows1>(expr_type(lhs, rhs)); -} - - -/** - * \fn MtM_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Rows1, Cols2>& rhs) - * \brief Function for the trans(matrix)-matrix-product. - * using formula - * \f[ - * M_1^{T}\,M_2 - * \f] - * \note The number of cols of matrix 2 have to be equal to number of rows of - * matrix 1, since matrix 1 is trans - the result is a (Cols1 x Cols2) - * matrix. - * \ingroup _binary_function - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> // Rows2 = Rows1 -inline -XprMatrix< - XprMtMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Rows1, Cols2>, Cols2 // M2(Rows1, Cols2) - >, - Cols1, Cols2 // return Dim -> -MtM_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Rows1, Cols2>& rhs) { - typedef XprMtMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, - XprMatrix<E2, Rows1, Cols2>, Cols2 - > expr_type; - return XprMatrix<expr_type, Cols1, Cols2>(expr_type(lhs, rhs)); -} - - -/** - * \fn MMt_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Rows2, Cols1>& rhs) - * \brief Function for the matrix-trans(matrix)-product. - * \ingroup _binary_function - * \note The cols2 has to be equal to cols1. - */ -template<class E1, int Rows1, int Cols1, - class E2, int Rows2> // Cols2 = Cols1 -inline -XprMatrix< - XprMMtProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Rows2, Cols1>, Cols1 // M2(Rows2, Cols1) - >, - Rows1, Rows2 // return Dim -> -MMt_prod(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Rows2, Cols1>& rhs) { - typedef XprMMtProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, - XprMatrix<E2, Rows2, Cols1>, Cols1 - > expr_type; - return XprMatrix<expr_type, Rows1, Rows2>(expr_type(lhs, rhs)); -} - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix-vector specific prod( ... ) functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn prod(const XprMatrix<E1, Rows, Cols>& lhs, const XprVector<E2, Cols>& rhs) - * \brief Evaluate the product of XprMatrix and XprVector. - * \ingroup _binary_function - */ -template<class E1, int Rows, int Cols, - class E2> -inline -XprVector< - XprMVProduct< - XprMatrix<E1, Rows, Cols>, Rows, Cols, - XprVector<E2, Cols> - >, - Rows -> -prod(const XprMatrix<E1, Rows, Cols>& lhs, const XprVector<E2, Cols>& rhs) { - typedef XprMVProduct< - XprMatrix<E1, Rows, Cols>, Rows, Cols, - XprVector<E2, Cols> - > expr_type; - return XprVector<expr_type, Rows>(expr_type(lhs, rhs)); -} - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix specific functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn trans(const XprMatrix<E, Rows, Cols>& rhs) - * \brief Transpose an expression matrix. - * \ingroup _unary_function - */ -template<class E, int Rows, int Cols> -inline -XprMatrix< - XprMatrixTranspose< - XprMatrix<E, Rows, Cols> - >, - Cols, Rows -> -trans(const XprMatrix<E, Rows, Cols>& rhs) { - typedef XprMatrixTranspose< - XprMatrix<E, Rows, Cols> - > expr_type; - return XprMatrix<expr_type, Cols, Rows>(expr_type(rhs)); -} - - -#if 0 // XXX needs declaration of meta::Matrix<Sz, Sz, 0, 0>::trace -/* - * \fn trace(const XprMatrix<E, Sz, Sz>& m) - * \brief Compute the trace of a square matrix. - * \ingroup _unary_function - * - * Simply compute the trace of the given matrix as: - * \f[ - * \sum_{k = 0}^{Sz-1} m(k, k) - * \f] - */ -template<class E, int Sz> -inline -typename Traits<typename E::value_type>::sum_type -trace(const XprMatrix<E, Sz, Sz>& m) { - return meta::Matrix<Sz, Sz, 0, 0>::trace(m); -} -#endif - - -/** - * \fn row(const XprMatrix<E, Rows, Cols>& m, int no) - * \brief Returns a row vector of the given matrix. - * \ingroup _binary_function - */ -template<class E, int Rows, int Cols> -inline -XprVector< - XprMatrixRow< - XprMatrix<E, Rows, Cols>, - Rows, Cols - >, - Cols -> -row(const XprMatrix<E, Rows, Cols>& m, int no) { - typedef XprMatrixRow< - XprMatrix<E, Rows, Cols>, - Rows, Cols - > expr_type; - - return XprVector<expr_type, Cols>(expr_type(m, no)); -} - - -/** - * \fn col(const XprMatrix<E, Rows, Cols>& m, int no) - * \brief Returns a column vector of the given matrix. - * \ingroup _binary_function - */ -template<class E, int Rows, int Cols> -inline -XprVector< - XprMatrixCol< - XprMatrix<E, Rows, Cols>, - Rows, Cols - >, - Rows -> -col(const XprMatrix<E, Rows, Cols>& m, int no) { - typedef XprMatrixCol< - XprMatrix<E, Rows, Cols>, - Rows, Cols - > expr_type; - - return XprVector<expr_type, Cols>(expr_type(m, no)); -} - - -/** - * \fn diag(const XprMatrix<E, Sz, Sz>& m) - * \brief Returns the diagonal vector of the given square matrix. - * \ingroup _unary_function - */ -template<class E, int Sz> -inline -XprVector< - XprMatrixDiag< - XprMatrix<E, Sz, Sz>, - Sz - >, - Sz -> -diag(const XprMatrix<E, Sz, Sz>& m) { - typedef XprMatrixDiag< - XprMatrix<E, Sz, Sz>, - Sz> expr_type; - - return XprVector<expr_type, Sz>(expr_type(m)); -} - - -} // namespace tvmet - -#endif // TVMET_XPR_MATRIX_FUNCTIONS_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MatrixOperators.h b/tvmet-1.7.1/include/tvmet/xpr/MatrixOperators.h deleted file mode 100644 index 6f31d88f4..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MatrixOperators.h +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MatrixOperators.h,v 1.19 2005/03/09 09:48:03 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MATRIX_OPERATORS_H -#define TVMET_XPR_MATRIX_OPERATORS_H - -namespace tvmet { - - -/********************************************************* - * PART I: DECLARATION - *********************************************************/ - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Matrix arithmetic operators implemented by functions - * add, sub, mul and div - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * operator(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1,Cols2>& rhs) - * - * Note: operations +,-,*,/ are per se element wise. Further more, - * element wise operations make sense only for matrices of the same - * size [varg]. - */ -#define TVMET_DECLARE_MACRO(NAME, OP) \ -template<class E1, int Rows1, int Cols1, \ - class E2> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprMatrix<E1, Rows1, Cols1>, \ - XprMatrix<E2, Rows1, Cols1> \ - >, \ - Rows1, Cols1 \ -> \ -operator OP (const XprMatrix<E1, Rows1, Cols1>& lhs, \ - const XprMatrix<E2, Rows1, Cols1>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, +) // per se element wise -TVMET_DECLARE_MACRO(sub, -) // per se element wise -namespace element_wise { - TVMET_DECLARE_MACRO(mul, *) // see as prod() - TVMET_DECLARE_MACRO(div, /) // not defined for matrizes, must be element_wise -} -#undef TVMET_DECLARE_MACRO - - -/* - * operator(XprMatrix<E, Rows, Cols>, POD) - * operator(POD, XprMatrix<E, Rows, Cols>) - * Note: operations +,-,*,/ are per se element wise - */ -#define TVMET_DECLARE_MACRO(NAME, OP, POD) \ -template<class E, int Rows, int Cols> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, POD >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< POD > \ - >, \ - Rows, Cols \ -> \ -operator OP (const XprMatrix<E, Rows, Cols>& lhs, \ - POD rhs) _tvmet_always_inline; \ - \ -template<class E,int Rows, int Cols> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -operator OP (POD lhs, \ - const XprMatrix<E, Rows, Cols>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, +, int) -TVMET_DECLARE_MACRO(sub, -, int) -TVMET_DECLARE_MACRO(mul, *, int) -TVMET_DECLARE_MACRO(div, /, int) - -TVMET_DECLARE_MACRO(add, +, float) -TVMET_DECLARE_MACRO(sub, -, float) -TVMET_DECLARE_MACRO(mul, *, float) -TVMET_DECLARE_MACRO(div, /, float) - -TVMET_DECLARE_MACRO(add, +, double) -TVMET_DECLARE_MACRO(sub, -, double) -TVMET_DECLARE_MACRO(mul, *, double) -TVMET_DECLARE_MACRO(div, /, double) - -#undef TVMET_DECLARE_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * operator(XprMatrix<E, Rows, Cols>, complex<>) - * operator(complex<>, XprMatrix<E, Rows, Cols>) - * Note: operations +,-,*,/ are per se element wise - * \todo type promotion - */ -#define TVMET_DECLARE_MACRO(NAME, OP) \ -template<class E, int Rows, int Cols, class T> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, std::complex<T> >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< std::complex<T> > \ - >, \ - Rows, Cols \ -> \ -operator OP (const XprMatrix<E, Rows, Cols>& lhs, \ - const std::complex<T>& rhs) _tvmet_always_inline; \ - \ -template<class E, int Rows, int Cols, class T> \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -operator OP (const std::complex<T>& lhs, \ - const XprMatrix<E, Rows, Cols>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, +) -TVMET_DECLARE_MACRO(sub, -) -TVMET_DECLARE_MACRO(mul, *) -TVMET_DECLARE_MACRO(div, /) - -#undef TVMET_DECLARE_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix specific operator*() = prod() operations - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn operator*(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) - * \brief Evaluate the product of two XprMatrix. - * \ingroup _binary_operator - * \sa prod(XprMatrix<E1, Rows1, Cols1> lhs, XprMatrix<E2, Cols1, Cols2> rhs) - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -XprMatrix< - XprMMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Cols1, Cols2>, Cols2 // M2(Cols1, Cols2) - >, - Rows1, Cols2 -> -operator*(const XprMatrix<E1, Rows1, Cols1>& lhs, - const XprMatrix<E2, Cols1, Cols2>& rhs) _tvmet_always_inline; - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix-vector specific prod( ... ) operators - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn operator*(const XprMatrix<E1, Rows, Cols>& lhs, const XprVector<E2, Cols>& rhs) - * \brief Evaluate the product of XprMatrix and XprVector. - * \ingroup _binary_operator - * \sa prod(XprMatrix<E1, Rows, Cols> lhs, XprVector<E2, Cols> rhs) - */ -template<class E1, int Rows, int Cols, - class E2> -XprVector< - XprMVProduct< - XprMatrix<E1, Rows, Cols>, Rows, Cols, - XprVector<E2, Cols> - >, - Rows -> -operator*(const XprMatrix<E1, Rows, Cols>& lhs, - const XprVector<E2, Cols>& rhs) _tvmet_always_inline; - - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * global unary operators - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * unary_operator(const XprMatrix<E, Rows, Cols>& m) - * Note: per se element wise - */ -#define TVMET_DECLARE_MACRO(NAME, OP) \ -template <class E, int Rows, int Cols> \ -XprMatrix< \ - XprUnOp< \ - Fcnl_##NAME<typename E::value_type>, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -operator OP (const XprMatrix<E, Rows, Cols>& m) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(neg, -) - -#undef TVMET_DECLARE_MACRO - - -/********************************************************* - * PART II: IMPLEMENTATION - *********************************************************/ - - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Matrix arithmetic operators implemented by functions - * add, sub, mul and div - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * operator(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1,Cols2>& rhs) - * - * Note: operations +,-,*,/ are per se element wise. Further more, - * element wise operations make sense only for matrices of the same - * size [varg]. - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP) \ -template<class E1, int Rows1, int Cols1, \ - class E2> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprMatrix<E1, Rows1, Cols1>, \ - XprMatrix<E2, Rows1, Cols1> \ - >, \ - Rows1, Cols1 \ -> \ -operator OP (const XprMatrix<E1, Rows1, Cols1>& lhs, \ - const XprMatrix<E2, Rows1, Cols1>& rhs) { \ - return NAME (lhs, rhs); \ -} - -TVMET_IMPLEMENT_MACRO(add, +) // per se element wise -TVMET_IMPLEMENT_MACRO(sub, -) // per se element wise -namespace element_wise { - TVMET_IMPLEMENT_MACRO(mul, *) // see as prod() - TVMET_IMPLEMENT_MACRO(div, /) // not defined for matrizes, must be element_wise -} -#undef TVMET_IMPLEMENT_MACRO - - -/* - * operator(XprMatrix<E, Rows, Cols>, POD) - * operator(POD, XprMatrix<E, Rows, Cols>) - * Note: operations +,-,*,/ are per se element wise - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP, POD) \ -template<class E, int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, POD >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< POD > \ - >, \ - Rows, Cols \ -> \ -operator OP (const XprMatrix<E, Rows, Cols>& lhs, POD rhs) { \ - return NAME (lhs, rhs); \ -} \ - \ -template<class E,int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -operator OP (POD lhs, const XprMatrix<E, Rows, Cols>& rhs) { \ - return NAME (lhs, rhs); \ -} - -TVMET_IMPLEMENT_MACRO(add, +, int) -TVMET_IMPLEMENT_MACRO(sub, -, int) -TVMET_IMPLEMENT_MACRO(mul, *, int) -TVMET_IMPLEMENT_MACRO(div, /, int) - -TVMET_IMPLEMENT_MACRO(add, +, float) -TVMET_IMPLEMENT_MACRO(sub, -, float) -TVMET_IMPLEMENT_MACRO(mul, *, float) -TVMET_IMPLEMENT_MACRO(div, /, float) - -TVMET_IMPLEMENT_MACRO(add, +, double) -TVMET_IMPLEMENT_MACRO(sub, -, double) -TVMET_IMPLEMENT_MACRO(mul, *, double) -TVMET_IMPLEMENT_MACRO(div, /, double) - -#undef TVMET_IMPLEMENT_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * operator(XprMatrix<E, Rows, Cols>, complex<>) - * operator(complex<>, XprMatrix<E, Rows, Cols>) - * Note: operations +,-,*,/ are per se element wise - * \todo type promotion - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP) \ -template<class E, int Rows, int Cols, class T> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, std::complex<T> >, \ - XprMatrix<E, Rows, Cols>, \ - XprLiteral< std::complex<T> > \ - >, \ - Rows, Cols \ -> \ -operator OP (const XprMatrix<E, Rows, Cols>& lhs, \ - const std::complex<T>& rhs) { \ - return NAME (lhs, rhs); \ -} \ - \ -template<class E, int Rows, int Cols, class T> \ -inline \ -XprMatrix< \ - XprBinOp< \ - Fcnl_##NAME<std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -operator OP (const std::complex<T>& lhs, \ - const XprMatrix<E, Rows, Cols>& rhs) { \ - return NAME (lhs, rhs); \ -} - -TVMET_IMPLEMENT_MACRO(add, +) -TVMET_IMPLEMENT_MACRO(sub, -) -TVMET_IMPLEMENT_MACRO(mul, *) -TVMET_IMPLEMENT_MACRO(div, /) - -#undef TVMET_IMPLEMENT_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix specific operator*() = prod() operations - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn operator*(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) - * \brief Evaluate the product of two XprMatrix. - * \ingroup _binary_operator - * \sa prod(XprMatrix<E1, Rows1, Cols1> lhs, XprMatrix<E2, Cols1, Cols2> rhs) - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -inline -XprMatrix< - XprMMProduct< - XprMatrix<E1, Rows1, Cols1>, Rows1, Cols1, // M1(Rows1, Cols1) - XprMatrix<E2, Cols1, Cols2>, Cols2 // M2(Cols1, Cols2) - >, - Rows1, Cols2 -> -operator*(const XprMatrix<E1, Rows1, Cols1>& lhs, const XprMatrix<E2, Cols1, Cols2>& rhs) { - return prod(lhs, rhs); -} - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * matrix-vector specific prod( ... ) operators - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn operator*(const XprMatrix<E1, Rows, Cols>& lhs, const XprVector<E2, Cols>& rhs) - * \brief Evaluate the product of XprMatrix and XprVector. - * \ingroup _binary_operator - * \sa prod(XprMatrix<E1, Rows, Cols> lhs, XprVector<E2, Cols> rhs) - */ -template<class E1, int Rows, int Cols, - class E2> -inline -XprVector< - XprMVProduct< - XprMatrix<E1, Rows, Cols>, Rows, Cols, - XprVector<E2, Cols> - >, - Rows -> -operator*(const XprMatrix<E1, Rows, Cols>& lhs, const XprVector<E2, Cols>& rhs) { - return prod(lhs, rhs); -} - - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * global unary operators - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * unary_operator(const XprMatrix<E, Rows, Cols>& m) - * Note: per se element wise - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP) \ -template <class E, int Rows, int Cols> \ -inline \ -XprMatrix< \ - XprUnOp< \ - Fcnl_##NAME<typename E::value_type>, \ - XprMatrix<E, Rows, Cols> \ - >, \ - Rows, Cols \ -> \ -operator OP (const XprMatrix<E, Rows, Cols>& m) { \ - typedef XprUnOp< \ - Fcnl_##NAME<typename E::value_type>, \ - XprMatrix<E, Rows, Cols> \ - > expr_type; \ - return XprMatrix<expr_type, Rows, Cols>(expr_type(m)); \ -} - -TVMET_IMPLEMENT_MACRO(neg, -) - -#undef TVMET_IMPLEMENT_MACRO - - -} // namespace tvmet - -#endif // TVMET_XPR_MATRIX_OPERATORS_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MatrixRow.h b/tvmet-1.7.1/include/tvmet/xpr/MatrixRow.h deleted file mode 100644 index d8a796858..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MatrixRow.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MatrixRow.h,v 1.14 2004/09/16 09:14:18 opetzold Exp $ - */ - -#include <cassert> - -#ifndef TVMET_XPR_MATRIX_ROW_H -#define TVMET_XPR_MATRIX_ROW_H - -namespace tvmet { - - -/** - * \class XprMatrixRow MatrixRow.h "tvmet/xpr/MatrixRow.h" - * \brief Expression on matrix used for access on the row vector. - */ -template<class E, int Rows, int Cols> -class XprMatrixRow - : public TvmetBase< XprMatrixRow<E, Rows, Cols> > -{ - XprMatrixRow(); - XprMatrixRow& operator=(const XprMatrixRow&); - -public: - typedef typename E::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_expr = E::ops, - ops = ops_expr/Rows // equal Col accesses - }; - -public: - /** Constructor. */ - explicit XprMatrixRow(const E& e, int no) - : m_expr(e), m_row(no) - { - assert(no < Rows); - } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMatrixRow(const XprMatrixRow& rhs) - : m_expr(rhs.m_expr), m_row(rhs.m_row) - { } -#endif - - value_type operator()(int j) const { - assert(j < Cols); - return m_expr(m_row, j); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMatrixRow[O=" << ops << ", (O=" << ops_expr << ")]<" - << std::endl; - m_expr.print_xpr(os, l); - os << IndentLevel(l) - << "R=" << Rows << ", C=" << Cols << std::endl - << IndentLevel(--l) << ">" - << ((l != 0) ? "," : "") << std::endl; - } - -private: - const E m_expr; - const int m_row; -}; - - -} - -#endif // TVMET_XPR_MATRIX_ROW_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MatrixTranspose.h b/tvmet-1.7.1/include/tvmet/xpr/MatrixTranspose.h deleted file mode 100644 index c51df513e..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MatrixTranspose.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MatrixTranspose.h,v 1.11 2004/06/10 16:36:55 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MATRIX_TRANSPOSE_H -#define TVMET_XPR_MATRIX_TRANSPOSE_H - -namespace tvmet { - - -/** - * \class XprMatrixTranspose MatrixTranspose.h "tvmet/xpr/MatrixTranspose.h" - * \brief Expression for transpose matrix - */ -template<class E> -class XprMatrixTranspose - : public TvmetBase< XprMatrixTranspose<E> > -{ - XprMatrixTranspose(); - XprMatrixTranspose& operator=(const XprMatrixTranspose&); - -public: - typedef typename E::value_type value_type; - - /** Complexity counter. */ - enum { - ops_expr = E::ops, - ops = 1 * ops_expr - }; - -public: - /** Constructor. */ - explicit XprMatrixTranspose(const E& e) - : m_expr(e) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMatrixTranspose(const XprMatrixTranspose& e) - : m_expr(e.m_expr) - { } -#endif - - /** index operator for arrays/matrices. This simple swap the index - access for transpose. */ - value_type operator()(int i, int j) const { return m_expr(j, i); } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMatrixTranspose[O=" << ops << ", (O=" << ops_expr << ")]<" - << std::endl; - m_expr.print_xpr(os, l); - os << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E m_expr; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MATRIX_TRANSPOSE_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h deleted file mode 100644 index 6d657d086..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MtMProduct.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MtMProduct.h,v 1.15 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MTMPRODUCT_H -#define TVMET_XPR_MTMPRODUCT_H - -#include <cassert> - -#include <tvmet/meta/Gemtm.h> -#include <tvmet/loop/Gemtm.h> - -namespace tvmet { - - -/** - * \class XprMtMProduct MtMProduct.h "tvmet/xpr/MtMProduct.h" - * \brief Expression for product of transposed(matrix)-matrix product. - * using formula - * \f[ - * M_1^{T}\,M_2 - * \f] - * \note The number of rows of rhs matrix have to be equal rows of rhs matrix, - * since lhs matrix 1 is transposed. - * The result is a (Cols1 x Cols2) matrix. - */ -template<class E1, int Rows1, int Cols1, - class E2, int Cols2> -class XprMtMProduct - : public TvmetBase< XprMtMProduct<E1, Rows1, Cols1, E2, Cols2> > -{ -private: - XprMtMProduct(); - XprMtMProduct& operator=(const XprMtMProduct&); - -public: - typedef typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_lhs = E1::ops, - ops_rhs = E2::ops, - M = Rows1 * Cols1 * Cols2, - N = (Rows1-1) * Cols1 * Cols2, - ops_plus = M * Traits<value_type>::ops_plus, - ops_muls = N * Traits<value_type>::ops_muls, - ops = ops_plus + ops_muls, - use_meta = Cols1*Cols2 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false - }; - -public: - /** Constructor. */ - explicit XprMtMProduct(const E1& lhs, const E2& rhs) - : m_lhs(lhs), m_rhs(rhs) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMtMProduct(const XprMtMProduct& e) - : m_lhs(e.m_lhs), m_rhs(e.m_rhs) { } -#endif - -private: - /** Wrapper for meta gemm. */ - static inline - value_type do_gemtm(dispatch<true>, const E1& lhs, const E2& rhs, int i, int j) { - return meta::gemtm<Rows1, Cols1, - Cols2, - 0>::prod(lhs, rhs, i, j); - } - - /** Wrapper for loop gemm. */ - static inline - value_type do_gemtm(dispatch<false>, const E1& lhs, const E2& rhs, int i, int j) { - return loop::gemtm<Rows1, Cols1, - Cols2>::prod(lhs, rhs, i, j); - } - -public: - /** index operator for arrays/matrices */ - value_type operator()(int i, int j) const { - assert((i < Cols1) && (j < Cols2)); - return do_gemtm(dispatch<use_meta>(), m_lhs, m_rhs, i, j); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMtMProduct[" - << (use_meta ? "M" : "L") << ", O=" << ops - << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<" - << std::endl; - m_lhs.print_xpr(os, l); - os << IndentLevel(l) - << "R1=" << Rows1 << ", C1=" << Cols1 << ",\n"; - m_rhs.print_xpr(os, l); - os << IndentLevel(l) - << "C2=" << Cols2 << ",\n" - << IndentLevel(l) - << "\n" - << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E1 m_lhs; - const E2 m_rhs; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MTMPRODUCT_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h b/tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h deleted file mode 100644 index a50bacc97..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/MtVProduct.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: MtVProduct.h,v 1.10 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_MTVPRODUCT_H -#define TVMET_XPR_MTVPRODUCT_H - -#include <cassert> - -#include <tvmet/meta/Gemtv.h> -#include <tvmet/loop/Gemtv.h> - -namespace tvmet { - - -/** - * \class XprMtVProduct MtVProduct.h "tvmet/xpr/MtVProduct.h" - * \brief Expression for matrix-transposed vector product - * using formula - * \f[ - * M^T\,v - * \f] - */ -template<class E1, int Rows, int Cols, - class E2> -class XprMtVProduct - : public TvmetBase< XprMtVProduct<E1, Rows, Cols, E2> > -{ - XprMtVProduct(); - XprMtVProduct& operator=(const XprMtVProduct&); - -public: - typedef typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_lhs = E1::ops, - ops_rhs = E2::ops, - M = Cols * Rows, - N = Cols * (Rows - 1), - ops_plus = M * Traits<value_type>::ops_plus, - ops_muls = N * Traits<value_type>::ops_muls, - ops = ops_plus + ops_muls, - use_meta = Rows*Cols < TVMET_COMPLEXITY_MV_TRIGGER ? true : false - }; - -public: - /** Constructor. */ - explicit XprMtVProduct(const E1& lhs, const E2& rhs) - : m_lhs(lhs), m_rhs(rhs) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprMtVProduct(const XprMtVProduct& e) - : m_lhs(e.m_lhs), m_rhs(e.m_rhs) - { } -#endif - -private: - /** Wrapper for meta gemm. */ - static inline - value_type do_gemtv(dispatch<true>, const E1& lhs, const E2& rhs, int i) { - return meta::gemtv<Rows, Cols, 0>::prod(lhs, rhs, i); - } - - /** Wrapper for loop gemm. */ - static inline - value_type do_gemtv(dispatch<false>, const E1& lhs, const E2& rhs, int i) { - return loop::gemtv<Rows, Cols>::prod(lhs, rhs, i); - } - -public: - /** index operator, returns the expression by index. This is the vector - style since a matrix*vector gives a vector. */ - value_type operator()(int j) const { - assert(j < Cols); - return do_gemtv(dispatch<use_meta>(), m_lhs, m_rhs, j); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprMtVProduct[O=" << ops << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<" - << std::endl; - m_lhs.print_xpr(os, l); - os << IndentLevel(l) - << "R=" << Rows << ", C=" << Cols << ",\n"; - m_rhs.print_xpr(os, l); - os << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E1 m_lhs; - const E2 m_rhs; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_MTVPRODUCT_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/Null.h b/tvmet-1.7.1/include/tvmet/xpr/Null.h deleted file mode 100644 index 68396f445..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/Null.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: Null.h,v 1.7 2003/11/30 18:35:17 opetzold Exp $ - */ - -#ifndef TVMET_XPR_NULL_H -#define TVMET_XPR_NULL_H - -namespace tvmet { - - -/** - * \class XprNull Null.h "tvmet/xpr/Null.h" - * \brief Null object design pattern - */ -class XprNull - : public TvmetBase< XprNull > -{ - XprNull& operator=(const XprNull&); - -public: - explicit XprNull() { } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l) << "XprNull[O=0]" << std::endl; - } -}; - - -#define TVMET_BINARY_OPERATOR(OP) \ -template< class T > \ -inline \ -T operator OP (const T& lhs, XprNull) { return lhs; } - -TVMET_BINARY_OPERATOR(+) -TVMET_BINARY_OPERATOR(-) -TVMET_BINARY_OPERATOR(*) -TVMET_BINARY_OPERATOR(/) - -#undef TVMET_BINARY_OPERATOR - - -} // namespace tvmet - -#endif // TVMET_XPR_NULL_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/UnOperator.h b/tvmet-1.7.1/include/tvmet/xpr/UnOperator.h deleted file mode 100644 index 3c4b87f49..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/UnOperator.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: UnOperator.h,v 1.13 2003/11/30 18:35:17 opetzold Exp $ - */ - -#ifndef TVMET_XPR_UNOPERATOR_H -#define TVMET_XPR_UNOPERATOR_H - -namespace tvmet { - - -/** - * \class XprUnOp UnOperator.h "tvmet/xpr/UnOperator.h" - * \brief Unary operator working on one subexpression. - * - * Using the access operator() the unary operation will be evaluated. - */ -template<class UnOp, class E> -class XprUnOp - : public TvmetBase< XprUnOp<UnOp, E> > -{ - XprUnOp(); - XprUnOp& operator=(const XprUnOp&); - -public: - typedef typename UnOp::value_type value_type; - -public: - /** Complexity counter. */ - enum { - ops_expr = E::ops, - ops = 1 * ops_expr - }; - -public: - /** Constructor for an expressions. */ - explicit XprUnOp(const E& e) - : m_expr(e) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprUnOp(const XprUnOp& e) - : m_expr(e.m_expr) - { } -#endif - - /** Index operator, evaluates the expression inside. */ - value_type operator()(int i) const { - return UnOp::apply_on(m_expr(i)); - } - - /** index operator for arrays/matrices. */ - value_type operator()(int i, int j) const { - return UnOp::apply_on(m_expr(i, j)); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprUnOp[O="<< ops << ", (O=" << ops_expr << ")]<" - << std::endl; - UnOp::print_xpr(os, l); - m_expr.print_xpr(os, l); - os << IndentLevel(--l) - << ">," << std::endl; - } - -private: - const E m_expr; -}; - - -} // namespace tvmet - -#endif // TVMET_XPR_UNOPERATOR_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/Vector.h b/tvmet-1.7.1/include/tvmet/xpr/Vector.h deleted file mode 100644 index 65db2a1f1..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/Vector.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: Vector.h,v 1.24 2004/09/16 09:14:18 opetzold Exp $ - */ - -#ifndef TVMET_XPR_VECTOR_H -#define TVMET_XPR_VECTOR_H - -#include <tvmet/meta/Vector.h> -#include <tvmet/loop/Vector.h> - -namespace tvmet { - - -/* forwards */ -template <class T, int Sz> class Vector; - -/** - * \class XprVector Vector.h "tvmet/xpr/Vector.h" - * \brief Represents the expression for vectors at any node in the parse tree. - * - * Specifically, XprVector is the class that wraps the expression, and the - * expression itself is represented by the template parameter E. The - * class XprVector is known as an anonymizing expression wrapper because - * it can hold any subexpression of arbitrary complexity, allowing - * clients to work with any expression by holding on to it via the - * wrapper, without having to know the name of the type object that - * actually implements the expression. - * \note leave the Ctors non-explicit to allow implicit type conversation. - */ -template<class E, int Sz> -class XprVector : public TvmetBase< XprVector<E, Sz> > -{ - XprVector(); - XprVector& operator=(const XprVector&); - -public: - typedef typename E::value_type value_type; - -public: - /** Dimensions. */ - enum { - Size = Sz /**< The size of the vector. */ - }; - -public: - /** Complexity counter */ - enum { - ops_assign = Size, - ops = E::ops, - use_meta = ops_assign < TVMET_COMPLEXITY_V_ASSIGN_TRIGGER ? true : false - }; - -public: - /** Constructor. */ - explicit XprVector(const E& e) - : m_expr(e) - { } - - /** Copy Constructor. Not explicit! */ -#if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) - XprVector(const XprVector& e) - : m_expr(e.m_expr) - { } -#endif - - /** const index operator for vectors. */ - value_type operator()(int i) const { - assert(i < Size); - return m_expr(i); - } - - /** const index operator for vectors. */ - value_type operator[](int i) const { - return this->operator()(i); - } - -private: - /** Wrapper for meta assign. */ - template<class Dest, class Src, class Assign> - static inline - void do_assign(dispatch<true>, Dest& dest, const Src& src, const Assign& assign_fn) { - meta::Vector<Size, 0>::assign(dest, src, assign_fn); - } - - /** Wrapper for loop assign. */ - template<class Dest, class Src, class Assign> - static inline - void do_assign(dispatch<false>, Dest& dest, const Src& src, const Assign& assign_fn) { - loop::Vector<Size>::assign(dest, src, assign_fn); - } - -public: - /** assign this expression to Vector dest. */ - template<class Dest, class Assign> - void assign_to(Dest& dest, const Assign& assign_fn) const { - /* here is a way for caching, since each complex 'Node' - is of type XprVector. */ - do_assign(dispatch<use_meta>(), dest, *this, assign_fn); - } - -public: // debugging Xpr parse tree - void print_xpr(std::ostream& os, int l=0) const { - os << IndentLevel(l++) - << "XprVector[" - << (use_meta ? "M" : "L") << ", O=" << ops << "]<" - << std::endl; - m_expr.print_xpr(os, l); - os << IndentLevel(l) - << "Sz=" << Size << std::endl; - os << IndentLevel(--l) << ">" - << ((l != 0) ? "," : "") << std::endl; - } - -private: - const E m_expr; -}; - - -} // namespace tvmet - -#include <tvmet/Functional.h> - -#include <tvmet/xpr/BinOperator.h> -#include <tvmet/xpr/UnOperator.h> -#include <tvmet/xpr/Literal.h> - -#include <tvmet/xpr/VectorFunctions.h> -#include <tvmet/xpr/VectorOperators.h> -#include <tvmet/xpr/Eval.h> - -#endif // TVMET_XPR_VECTOR_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h b/tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h deleted file mode 100644 index 172ed7ab2..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/VectorFunctions.h +++ /dev/null @@ -1,655 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: VectorFunctions.h,v 1.17 2005/03/25 07:11:29 opetzold Exp $ - */ - -#ifndef TVMET_XPR_VECTOR_FUNCTIONS_H -#define TVMET_XPR_VECTOR_FUNCTIONS_H - -namespace tvmet { - - -/* forwards */ -template<class T, int Sz> class Vector; - - -/********************************************************* - * PART I: DECLARATION - *********************************************************/ - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Vector arithmetic functions add, sub, mul and div - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * function(XprVector<E1, Sz>, XprVector<E2, Sz>) - */ -#define TVMET_DECLARE_MACRO(NAME) \ -template<class E1, class E2, int Sz> \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprVector<E1, Sz>, \ - XprVector<E2, Sz> \ - >, \ - Sz \ -> \ -NAME (const XprVector<E1, Sz>& lhs, \ - const XprVector<E2, Sz>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add) // per se element wise -TVMET_DECLARE_MACRO(sub) // per se element wise -TVMET_DECLARE_MACRO(mul) // per se element wise -namespace element_wise { - TVMET_DECLARE_MACRO(div) // not defined for vectors -} - -#undef TVMET_DECLARE_MACRO - - -/* - * function(XprVector<E, Sz>, POD) - * function(POD, XprVector<E, Sz>) - * Note: - operations +,-,*,/ are per se element wise - */ -#define TVMET_DECLARE_MACRO(NAME, POD) \ -template<class E, int Sz> \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< typename E::value_type, POD >, \ - XprVector<E, Sz>, \ - XprLiteral< POD > \ - >, \ - Sz \ -> \ -NAME (const XprVector<E, Sz>& lhs, \ - POD rhs) _tvmet_always_inline; \ - \ -template<class E, int Sz> \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprVector<E, Sz> \ - >, \ - Sz \ -> \ -NAME (POD lhs, \ - const XprVector<E, Sz>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, int) -TVMET_DECLARE_MACRO(sub, int) -TVMET_DECLARE_MACRO(mul, int) -TVMET_DECLARE_MACRO(div, int) - -TVMET_DECLARE_MACRO(add, float) -TVMET_DECLARE_MACRO(sub, float) -TVMET_DECLARE_MACRO(mul, float) -TVMET_DECLARE_MACRO(div, float) - -TVMET_DECLARE_MACRO(add, double) -TVMET_DECLARE_MACRO(sub, double) -TVMET_DECLARE_MACRO(mul, double) -TVMET_DECLARE_MACRO(div, double) - -#undef TVMET_DECLARE_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * function(XprMatrix<E, Rows, Cols>, complex<T>) - * function(complex<T>, XprMatrix<E, Rows, Cols>) - * Note: - operations +,-,*,/ are per se element wise - * \todo type promotion - */ -#define TVMET_DECLARE_MACRO(NAME) \ -template<class E, int Sz, class T> \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< typename E::value_type, std::complex<T> >, \ - XprVector<E, Sz>, \ - XprLiteral< std::complex<T> > \ - >, \ - Sz \ -> \ -NAME (const XprVector<E, Sz>& lhs, \ - const std::complex<T>& rhs) _tvmet_always_inline; \ - \ -template<class E, int Sz, class T> \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprVector<E, Sz> \ - >, \ - Sz \ -> \ -NAME (const std::complex<T>& lhs, \ - const XprVector<E, Sz>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add) -TVMET_DECLARE_MACRO(sub) -TVMET_DECLARE_MACRO(mul) -TVMET_DECLARE_MACRO(div) - -#undef TVMET_DECLARE_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * vector specific functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -template<class E, int Sz> -typename Traits<typename E::value_type>::sum_type -sum(const XprVector<E, Sz>& v) _tvmet_always_inline; - - -template<class E, int Sz> -typename Traits<typename E::value_type>::sum_type -product(const XprVector<E, Sz>& v) _tvmet_always_inline; - - -template<class E1, class E2, int Sz> -typename PromoteTraits< - typename E1::value_type, - typename E2::value_type ->::value_type -dot(const XprVector<E1, Sz>& lhs, - const XprVector<E2, Sz>& rhs) _tvmet_always_inline; - - -template<class T, class E, int Sz> -typename PromoteTraits<T, typename E::value_type>::value_type -dot(const Vector<T, Sz>& lhs, - const XprVector<E, Sz>& rhs) _tvmet_always_inline; - - -template<class E, class T, int Sz> -typename PromoteTraits<T, typename E::value_type>::value_type -dot(const XprVector<E, Sz>& lhs, - const Vector<T, Sz>& rhs) _tvmet_always_inline; - - -template<class E1, class E2> -Vector< - typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type, - 3 -> -cross(const XprVector<E1, 3>& lhs, - const XprVector<E2, 3>& rhs) _tvmet_always_inline; - - -template<class T, class E> -Vector< - typename PromoteTraits<T, typename E::value_type>::value_type, 3> -cross(const Vector<T, 3>& lhs, - const XprVector<E, 3>& rhs) _tvmet_always_inline; - - -template<class E, class T> -Vector< - typename PromoteTraits<T, typename E::value_type>::value_type, 3> -cross(const XprVector<E, 3>& lhs, - const Vector<T, 3>& rhs) _tvmet_always_inline; - - -template<class E, int Sz> -typename Traits<typename E::value_type>::sum_type -norm1(const XprVector<E, Sz>& v) _tvmet_always_inline; - - -template<class E, int Sz> -typename Traits<typename E::value_type>::sum_type -norm2(const XprVector<E, Sz>& v) _tvmet_always_inline; - - -template<class E, int Sz> -XprVector< - XprBinOp< - Fcnl_div<typename E::value_type, typename E::value_type>, - XprVector<E, Sz>, - XprLiteral<typename E::value_type> - >, - Sz -> -normalize(const XprVector<E, Sz>& v) _tvmet_always_inline; - - -/********************************************************* - * PART II: IMPLEMENTATION - *********************************************************/ - - -/* - * function(XprVector<E1, Sz>, XprVector<E2, Sz>) - */ -#define TVMET_IMPLEMENT_MACRO(NAME) \ -template<class E1, class E2, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprVector<E1, Sz>, \ - XprVector<E2, Sz> \ - >, \ - Sz \ -> \ -NAME (const XprVector<E1, Sz>& lhs, const XprVector<E2, Sz>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprVector<E1, Sz>, \ - XprVector<E2, Sz> \ - > expr_type; \ - return XprVector<expr_type, Sz>(expr_type(lhs, rhs)); \ -} - -TVMET_IMPLEMENT_MACRO(add) // per se element wise -TVMET_IMPLEMENT_MACRO(sub) // per se element wise -TVMET_IMPLEMENT_MACRO(mul) // per se element wise -namespace element_wise { - TVMET_IMPLEMENT_MACRO(div) // not defined for vectors -} - -#undef TVMET_IMPLEMENT_MACRO - - -/* - * function(XprVector<E, Sz>, POD) - * function(POD, XprVector<E, Sz>) - * Note: - operations +,-,*,/ are per se element wise - */ -#define TVMET_IMPLEMENT_MACRO(NAME, POD) \ -template<class E, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< typename E::value_type, POD >, \ - XprVector<E, Sz>, \ - XprLiteral< POD > \ - >, \ - Sz \ -> \ -NAME (const XprVector<E, Sz>& lhs, POD rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME< typename E::value_type, POD >, \ - XprVector<E, Sz>, \ - XprLiteral< POD > \ - > expr_type; \ - return XprVector<expr_type, Sz>( \ - expr_type(lhs, XprLiteral< POD >(rhs))); \ -} \ - \ -template<class E, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprVector<E, Sz> \ - >, \ - Sz \ -> \ -NAME (POD lhs, const XprVector<E, Sz>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type>, \ - XprLiteral< POD >, \ - XprVector<E, Sz> \ - > expr_type; \ - return XprVector<expr_type, Sz>( \ - expr_type(XprLiteral< POD >(lhs), rhs)); \ -} - -TVMET_IMPLEMENT_MACRO(add, int) -TVMET_IMPLEMENT_MACRO(sub, int) -TVMET_IMPLEMENT_MACRO(mul, int) -TVMET_IMPLEMENT_MACRO(div, int) - -TVMET_IMPLEMENT_MACRO(add, float) -TVMET_IMPLEMENT_MACRO(sub, float) -TVMET_IMPLEMENT_MACRO(mul, float) -TVMET_IMPLEMENT_MACRO(div, float) - -TVMET_IMPLEMENT_MACRO(add, double) -TVMET_IMPLEMENT_MACRO(sub, double) -TVMET_IMPLEMENT_MACRO(mul, double) -TVMET_IMPLEMENT_MACRO(div, double) - -#undef TVMET_IMPLEMENT_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * function(XprMatrix<E, Rows, Cols>, complex<T>) - * function(complex<T>, XprMatrix<E, Rows, Cols>) - * Note: - operations +,-,*,/ are per se element wise - * \todo type promotion - */ -#define TVMET_IMPLEMENT_MACRO(NAME) \ -template<class E, int Sz, class T> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< typename E::value_type, std::complex<T> >, \ - XprVector<E, Sz>, \ - XprLiteral< std::complex<T> > \ - >, \ - Sz \ -> \ -NAME (const XprVector<E, Sz>& lhs, const std::complex<T>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME< typename E::value_type, std::complex<T> >, \ - XprVector<E, Sz>, \ - XprLiteral< std::complex<T> > \ - > expr_type; \ - return XprVector<expr_type, Sz>( \ - expr_type(lhs, XprLiteral< std::complex<T> >(rhs))); \ -} \ - \ -template<class E, int Sz, class T> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprVector<E, Sz> \ - >, \ - Sz \ -> \ -NAME (const std::complex<T>& lhs, const XprVector<E, Sz>& rhs) { \ - typedef XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type>, \ - XprLiteral< std::complex<T> >, \ - XprVector<E, Sz> \ - > expr_type; \ - return XprVector<expr_type, Sz>( \ - expr_type(XprLiteral< std::complex<T> >(lhs), rhs)); \ -} - -TVMET_IMPLEMENT_MACRO(add) -TVMET_IMPLEMENT_MACRO(sub) -TVMET_IMPLEMENT_MACRO(mul) -TVMET_IMPLEMENT_MACRO(div) - -#undef TVMET_IMPLEMENT_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * vector specific functions - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** - * \fn sum(const XprVector<E, Sz>& v) - * \brief Compute the sum of the vector expression. - * \ingroup _unary_function - * - * Simply compute the sum of the given vector as: - * \f[ - * \sum_{i = 0}^{Sz-1} v[i] - * \f] - */ -template<class E, int Sz> -inline -typename Traits<typename E::value_type>::sum_type -sum(const XprVector<E, Sz>& v) { - return meta::Vector<Sz>::sum(v); -} - - -/** - * \fn product(const XprVector<E, Sz>& v) - * \brief Compute the product of the vector elements. - * \ingroup _unary_function - * - * Simply computer the product of the given vector expression as: - * \f[ - * \prod_{i = 0}^{Sz - 1} v[i] - * \f] - */ -template<class E, int Sz> -inline -typename Traits<typename E::value_type>::sum_type -product(const XprVector<E, Sz>& v) { - return meta::Vector<Sz>::product(v); -} - - -/** - * \fn dot(const XprVector<E1, Sz>& lhs, const XprVector<E2, Sz>& rhs) - * \brief Compute the dot/inner product - * \ingroup _binary_function - * - * Compute the dot product as: - * \f[ - * \sum_{i = 0}^{Sz - 1} ( lhs[i] * rhs[i] ) - * \f] - * where lhs is a column vector and rhs is a row vector, both vectors - * have the same dimension. - */ -template<class E1, class E2, int Sz> -inline -typename PromoteTraits< - typename E1::value_type, - typename E2::value_type ->::value_type -dot(const XprVector<E1, Sz>& lhs, const XprVector<E2, Sz>& rhs) { - return meta::Vector<Sz>::dot(lhs, rhs); -} - - -/** - * \fn dot(const Vector<T, Sz>& lhs, const XprVector<E, Sz>& rhs) - * \brief Compute the dot/inner product - * \ingroup _binary_function - * - * Compute the dot product as: - * \f[ - * \sum_{i = 0}^{Sz - 1} ( lhs[i] * rhs[i] ) - * \f] - * where lhs is a column vector and rhs is a row vector, both vectors - * have the same dimension. - */ -template<class T, class E, int Sz> -inline -typename PromoteTraits<T, typename E::value_type>::value_type -dot(const Vector<T, Sz>& lhs, const XprVector<E, Sz>& rhs) { - return meta::Vector<Sz>::dot(lhs, rhs); -} - - -/** - * \fn dot(const XprVector<E, Sz>& lhs, const Vector<T, Sz>& rhs) - * \brief Compute the dot/inner product - * \ingroup _binary_function - * - * Compute the dot product as: - * \f[ - * \sum_{i = 0}^{Sz - 1} ( lhs[i] * rhs[i] ) - * \f] - * where lhs is a column vector and rhs is a row vector, both vectors - * have the same dimension. - */ -template<class E, class T, int Sz> -inline -typename PromoteTraits<T, typename E::value_type>::value_type -dot(const XprVector<E, Sz>& lhs, const Vector<T, Sz>& rhs) { - return meta::Vector<Sz>::dot(lhs, rhs); -} - - -/** - * \fn cross(const XprVector<E1, 3>& lhs, const XprVector<E2, 3>& rhs) - * \brief Compute the cross/outer product - * \ingroup _binary_function - * \note working only for vectors of size = 3 - * \todo Implement vector outer product as ET and MT, returning a XprVector - */ -template<class E1, class E2> -inline -Vector< - typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type, - 3 -> -cross(const XprVector<E1, 3>& lhs, const XprVector<E2, 3>& rhs) { - typedef typename PromoteTraits< - typename E1::value_type, - typename E2::value_type - >::value_type value_type; - return Vector<value_type, 3>(lhs(1)*rhs(2) - rhs(1)*lhs(2), - rhs(0)*lhs(2) - lhs(0)*rhs(2), - lhs(0)*rhs(1) - rhs(0)*lhs(1)); -} - - -/** - * \fn cross(const XprVector<E, 3>& lhs, const Vector<T, 3>& rhs) - * \brief Compute the cross/outer product - * \ingroup _binary_function - * \note working only for vectors of size = 3 - * \todo Implement vector outer product as ET and MT, returning a XprVector - */ -template<class E, class T> -inline -Vector< - typename PromoteTraits<T, typename E::value_type>::value_type, 3> -cross(const XprVector<E, 3>& lhs, const Vector<T, 3>& rhs) { - typedef typename PromoteTraits< - typename E::value_type, T>::value_type value_type; - return Vector<value_type, 3>(lhs(1)*rhs(2) - rhs(1)*lhs(2), - rhs(0)*lhs(2) - lhs(0)*rhs(2), - lhs(0)*rhs(1) - rhs(0)*lhs(1)); -} - - -/** - * \fn cross(const Vector<T, 3>& lhs, const XprVector<E, 3>& rhs) - * \brief Compute the cross/outer product - * \ingroup _binary_function - * \note working only for vectors of size = 3 - * \todo Implement vector outer product as ET and MT, returning a XprVector - */ -template<class T1, class E2> -inline -Vector< - typename PromoteTraits<T1, typename E2::value_type>::value_type, 3> -cross(const Vector<T1, 3>& lhs, const XprVector<E2, 3>& rhs) { - typedef typename PromoteTraits< - typename E2::value_type, T1>::value_type value_type; - return Vector<value_type, 3>(lhs(1)*rhs(2) - rhs(1)*lhs(2), - rhs(0)*lhs(2) - lhs(0)*rhs(2), - lhs(0)*rhs(1) - rhs(0)*lhs(1)); -} - - -/** - * \fn norm1(const XprVector<E, Sz>& v) - * \brief The \f$l_1\f$ norm of a vector expression. - * \ingroup _unary_function - * The norm of any vector is just the square root of the dot product of - * a vector with itself, or - * - * \f[ - * |Vector<T, Sz> v| = |v| = \sum_{i=0}^{Sz-1}\,|v[i]| - * \f] - */ -template<class E, int Sz> -inline -typename Traits<typename E::value_type>::sum_type -norm1(const XprVector<E, Sz>& v) { - return sum(abs(v)); -} - - -/** - * \fn norm2(const XprVector<E, Sz>& v) - * \brief The euklidian norm (or \f$l_2\f$ norm) of a vector expression. - * \ingroup _unary_function - * The norm of any vector is just the square root of the dot product of - * a vector with itself, or - * - * \f[ - * |Vector<T, Sz> v| = |v| = \sqrt{ \sum_{i=0}^{Sz-1}\,v[i]^2 } - * \f] - * - * \note The internal cast for Vector<int> avoids warnings on sqrt. - */ -template<class E, int Sz> -inline -typename Traits<typename E::value_type>::sum_type -norm2(const XprVector<E, Sz>& v) { - typedef typename E::value_type value_type; - return static_cast<value_type>( std::sqrt(static_cast<value_type>(dot(v, v))) ); -} - - -/** - * \fn normalize(const XprVector<E, Sz>& v) - * \brief Normalize the given vector expression. - * \ingroup _unary_function - * \sa norm2 - * - * using the equation: - * \f[ - * \frac{Vector<T, Sz> v}{\sqrt{ \sum_{i=0}^{Sz-1}\,v[i]^2 }} - * \f] - */ -template<class E, int Sz> -inline -XprVector< - XprBinOp< - Fcnl_div<typename E::value_type, typename E::value_type>, - XprVector<E, Sz>, - XprLiteral<typename E::value_type> - >, - Sz -> -normalize(const XprVector<E, Sz>& v) { - typedef typename E::value_type value_type; - typedef XprBinOp< - Fcnl_div<value_type, value_type>, - XprVector<E, Sz>, - XprLiteral<value_type> - > expr_type; - return XprVector<expr_type, Sz>( - expr_type(v, XprLiteral< value_type >(norm2(v)))); -} - - -} // namespace tvmet - -#endif // TVMET_XPR_VECTOR_FUNCTIONS_H - -// Local Variables: -// mode:C++ -// End: diff --git a/tvmet-1.7.1/include/tvmet/xpr/VectorOperators.h b/tvmet-1.7.1/include/tvmet/xpr/VectorOperators.h deleted file mode 100644 index 5f5bf6803..000000000 --- a/tvmet-1.7.1/include/tvmet/xpr/VectorOperators.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Tiny Vector Matrix Library - * Dense Vector Matrix Libary of Tiny size using Expression Templates - * - * Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net> - * - * 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: VectorOperators.h,v 1.13 2004/06/10 16:36:55 opetzold Exp $ - */ - -#ifndef TVMET_XPR_VECTOR_OPERATORS_H -#define TVMET_XPR_VECTOR_OPERATORS_H - -namespace tvmet { - - -/********************************************************* - * PART I: DECLARATION - *********************************************************/ - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Vector arithmetic operators implemented by functions - * add, sub, mul and div - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * operator(XprVector<E1, Sz>, XprVector<E2, Sz>) - */ -#define TVMET_DECLARE_MACRO(NAME, OP) \ -template<class E1, class E2, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprVector<E1, Sz>, \ - XprVector<E2, Sz> \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E1, Sz>& lhs, \ - const XprVector<E2, Sz>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, +) // per se element wise -TVMET_DECLARE_MACRO(sub, -) // per se element wise -TVMET_DECLARE_MACRO(mul, *) // per se element wise -namespace element_wise { - TVMET_DECLARE_MACRO(div, /) // not defined for vectors -} - -#undef TVMET_DECLARE_MACRO - - -/* - * operator(XprVector<E, Sz>, POD) - * operator(POD, XprVector<E, Sz>) - * Note: operations +,-,*,/ are per se element wise - */ -#define TVMET_DECLARE_MACRO(NAME, OP, POD) \ -template<class E, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, POD >, \ - XprVector<E, Sz>, \ - XprLiteral< POD > \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E, Sz>& lhs, \ - POD rhs) _tvmet_always_inline; \ - \ -template<class E, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type >, \ - XprLiteral< POD >, \ - XprVector< E, Sz> \ - >, \ - Sz \ -> \ -operator OP (POD lhs, \ - const XprVector<E, Sz>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, +, int) -TVMET_DECLARE_MACRO(sub, -, int) -TVMET_DECLARE_MACRO(mul, *, int) -TVMET_DECLARE_MACRO(div, /, int) - -TVMET_DECLARE_MACRO(add, +, float) -TVMET_DECLARE_MACRO(sub, -, float) -TVMET_DECLARE_MACRO(mul, *, float) -TVMET_DECLARE_MACRO(div, /, float) - -TVMET_DECLARE_MACRO(add, +, double) -TVMET_DECLARE_MACRO(sub, -, double) -TVMET_DECLARE_MACRO(mul, *, double) -TVMET_DECLARE_MACRO(div, /, double) - -#undef TVMET_DECLARE_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * operator(XprVector<E, Sz>, complex<T>) - * operator(complex<T>, XprVector<E, Sz>) - * Note: operations +,-,*,/ are per se element wise - */ -#define TVMET_DECLARE_MACRO(NAME, OP) \ -template<class E, int Sz, class T> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, std::complex<T> >, \ - XprVector<E, Sz>, \ - XprLiteral< std::complex<T> > \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E, Sz>& lhs, \ - const std::complex<T>& rhs) _tvmet_always_inline; \ - \ -template<class E, int Sz, class T> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type >, \ - XprLiteral< std::complex<T> >, \ - XprVector< E, Sz> \ - >, \ - Sz \ -> \ -operator OP (const std::complex<T>& lhs, \ - const XprVector<E, Sz>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(add, +) // per se element wise -TVMET_DECLARE_MACRO(sub, -) // per se element wise -TVMET_DECLARE_MACRO(mul, *) // per se element wise -TVMET_DECLARE_MACRO(div, /) // per se element wise - -#undef TVMET_DECLARE_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * global unary operators - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * Unary Operator on XprVector<E, Sz> - */ -#define TVMET_DECLARE_MACRO(NAME, OP) \ -template <class E, int Sz> \ -inline \ -XprVector< \ - XprUnOp< \ - Fcnl_##NAME<typename E::value_type>, \ - XprVector<E, Sz> \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E, Sz>& rhs) _tvmet_always_inline; - -TVMET_DECLARE_MACRO(neg, -) - -#undef TVMET_DECLARE_MACRO - - -/********************************************************* - * PART II: IMPLEMENTATION - *********************************************************/ - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * Vector arithmetic operators implemented by functions - * add, sub, mul and div - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * operator(XprVector<E1, Sz>, XprVector<E2, Sz>) - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP) \ -template<class E1, class E2, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E1::value_type, typename E2::value_type>, \ - XprVector<E1, Sz>, \ - XprVector<E2, Sz> \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E1, Sz>& lhs, \ - const XprVector<E2, Sz>& rhs) { \ - return NAME (lhs, rhs); \ -} - -TVMET_IMPLEMENT_MACRO(add, +) // per se element wise -TVMET_IMPLEMENT_MACRO(sub, -) // per se element wise -TVMET_IMPLEMENT_MACRO(mul, *) // per se element wise -namespace element_wise { - TVMET_IMPLEMENT_MACRO(div, /) // not defined for vectors -} - -#undef TVMET_IMPLEMENT_MACRO - - -/* - * operator(XprVector<E, Sz>, POD) - * operator(POD, XprVector<E, Sz>) - * Note: operations +,-,*,/ are per se element wise - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP, POD) \ -template<class E, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, POD >, \ - XprVector<E, Sz>, \ - XprLiteral< POD > \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E, Sz>& lhs, POD rhs) { \ - return NAME (lhs, rhs); \ -} \ - \ -template<class E, int Sz> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< POD, typename E::value_type >, \ - XprLiteral< POD >, \ - XprVector< E, Sz> \ - >, \ - Sz \ -> \ -operator OP (POD lhs, const XprVector<E, Sz>& rhs) { \ - return NAME (lhs, rhs); \ -} - -TVMET_IMPLEMENT_MACRO(add, +, int) -TVMET_IMPLEMENT_MACRO(sub, -, int) -TVMET_IMPLEMENT_MACRO(mul, *, int) -TVMET_IMPLEMENT_MACRO(div, /, int) - -TVMET_IMPLEMENT_MACRO(add, +, float) -TVMET_IMPLEMENT_MACRO(sub, -, float) -TVMET_IMPLEMENT_MACRO(mul, *, float) -TVMET_IMPLEMENT_MACRO(div, /, float) - -TVMET_IMPLEMENT_MACRO(add, +, double) -TVMET_IMPLEMENT_MACRO(sub, -, double) -TVMET_IMPLEMENT_MACRO(mul, *, double) -TVMET_IMPLEMENT_MACRO(div, /, double) - -#undef TVMET_IMPLEMENT_MACRO - - -#if defined(EIGEN_USE_COMPLEX) -/* - * operator(XprVector<E, Sz>, complex<T>) - * operator(complex<T>, XprVector<E, Sz>) - * Note: operations +,-,*,/ are per se element wise - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP) \ -template<class E, int Sz, class T> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME<typename E::value_type, std::complex<T> >, \ - XprVector<E, Sz>, \ - XprLiteral< std::complex<T> > \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E, Sz>& lhs, \ - const std::complex<T>& rhs) { \ - return NAME (lhs, rhs); \ -} \ - \ -template<class E, int Sz, class T> \ -inline \ -XprVector< \ - XprBinOp< \ - Fcnl_##NAME< std::complex<T>, typename E::value_type >, \ - XprLiteral< std::complex<T> >, \ - XprVector< E, Sz> \ - >, \ - Sz \ -> \ -operator OP (const std::complex<T>& lhs, \ - const XprVector<E, Sz>& rhs) { \ - return NAME (lhs, rhs); \ -} - -TVMET_IMPLEMENT_MACRO(add, +) // per se element wise -TVMET_IMPLEMENT_MACRO(sub, -) // per se element wise -TVMET_IMPLEMENT_MACRO(mul, *) // per se element wise -TVMET_IMPLEMENT_MACRO(div, /) // per se element wise - -#undef TVMET_IMPLEMENT_MACRO - -#endif // defined(EIGEN_USE_COMPLEX) - - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - * global unary operators - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/* - * Unary Operator on XprVector<E, Sz> - */ -#define TVMET_IMPLEMENT_MACRO(NAME, OP) \ -template <class E, int Sz> \ -inline \ -XprVector< \ - XprUnOp< \ - Fcnl_##NAME<typename E::value_type>, \ - XprVector<E, Sz> \ - >, \ - Sz \ -> \ -operator OP (const XprVector<E, Sz>& rhs) { \ - typedef XprUnOp< \ - Fcnl_##NAME<typename E::value_type>, \ - XprVector<E, Sz> \ - > expr_type; \ - return XprVector<expr_type, Sz>(expr_type(rhs)); \ -} - -TVMET_IMPLEMENT_MACRO(neg, -) - -#undef TVMET_IMPLEMENT_MACRO - - -} // namespace tvmet - -#endif // TVMET_XPR_VECTOR_OPERATORS_H - -// Local Variables: -// mode:C++ -// End: |