This is the Tiny Vector Matrix Expression Templates library found at http://tvmet.sourceforge.net. It is the fastest and most compact matrix lib out there (for < 10x10 matricies). I have done some minor tweaks to make it compile for mbed. For examples and hints on how to use, see: http://tvmet.sourceforge.net/usage.html
Dependents: Eurobot_2012_Secondary
MatrixRow.h
00001 /* 00002 * Tiny Vector Matrix Library 00003 * Dense Vector Matrix Libary of Tiny size using Expression Templates 00004 * 00005 * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net> 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * $Id: MatrixRow.h,v 1.18 2007-06-23 15:59:00 opetzold Exp $ 00022 */ 00023 00024 #ifndef TVMET_XPR_MATRIX_ROW_H 00025 #define TVMET_XPR_MATRIX_ROW_H 00026 00027 namespace tvmet { 00028 00029 00030 /** 00031 * \class XprMatrixRow MatrixRow.h "tvmet/xpr/MatrixRow.h" 00032 * \brief Expression on matrix used for access on the row vector. 00033 */ 00034 template<class E, std::size_t Rows, std::size_t Cols> 00035 class XprMatrixRow 00036 : public TvmetBase< XprMatrixRow<E, Rows, Cols> > 00037 { 00038 XprMatrixRow(); 00039 XprMatrixRow& operator=(const XprMatrixRow&); 00040 00041 public: 00042 typedef typename E::value_type value_type; 00043 00044 public: 00045 /** Complexity counter. */ 00046 enum { 00047 ops_expr = E::ops, 00048 ops = ops_expr/Rows // equal Col accesses 00049 }; 00050 00051 public: 00052 /** Constructor. */ 00053 explicit XprMatrixRow(const E& e, std::size_t no) 00054 : m_expr(e), m_row(no) 00055 { 00056 TVMET_RT_CONDITION(no < Rows, "XprMatrixRow Bounce Violation") 00057 } 00058 00059 /** Copy Constructor. Not explicit! */ 00060 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) 00061 XprMatrixRow(const XprMatrixRow& rhs) 00062 : m_expr(rhs.m_expr), m_row(rhs.m_row) 00063 { } 00064 #endif 00065 00066 value_type operator()(std::size_t j) const { 00067 TVMET_RT_CONDITION(j < Cols, "XprMatrixRow Bounce Violation") 00068 return m_expr(m_row, j); 00069 } 00070 00071 public: // debugging Xpr parse tree 00072 void print_xpr(std::ostream& os, std::size_t l=0) const { 00073 os << IndentLevel(l++) 00074 << "XprMatrixRow[O=" << ops << ", (O=" << ops_expr << ")]<" 00075 << std::endl; 00076 m_expr.print_xpr(os, l); 00077 os << IndentLevel(l) 00078 << "R=" << Rows << ", C=" << Cols << std::endl 00079 << IndentLevel(--l) << ">" 00080 << ((l != 0) ? "," : "") << std::endl; 00081 } 00082 00083 private: 00084 const E m_expr; 00085 const std::size_t m_row; 00086 }; 00087 00088 00089 } 00090 00091 #endif // TVMET_XPR_MATRIX_ROW_H 00092 00093 // Local Variables: 00094 // mode:C++ 00095 // tab-width:8 00096 // End:
Generated on Tue Jul 12 2022 19:00:11 by 1.7.2