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
AliasProxy.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: AliasProxy.h,v 1.8 2007-06-23 15:58:58 opetzold Exp $ 00022 */ 00023 00024 #ifndef TVMET_ALIAS_PROXY_H 00025 #define TVMET_ALIAS_PROXY_H 00026 00027 namespace tvmet { 00028 00029 00030 /** forwards */ 00031 template<class E> class AliasProxy; 00032 00033 00034 /** 00035 * \brief Simplify syntax for alias Matrices and Vectors, 00036 * where aliasing left hand values appear in the 00037 * expression. 00038 * \par Example: 00039 * \code 00040 * typedef tvmet::Matrix<double, 10, 10> matrix_type; 00041 * matrix_type m; 00042 * ... 00043 * alias(m) += trans(m); 00044 * \endcode 00045 * \sa AliasProxy 00046 * \sa Some Notes \ref alias 00047 */ 00048 template<class E> 00049 AliasProxy<E> alias(E& expr) { return AliasProxy<E>(expr); } 00050 00051 00052 /** 00053 * \class AliasProxy AliasProxy.h "tvmet/AliasProxy.h" 00054 * \brief Assign proxy for alias Matrices and Vectors. 00055 * 00056 * A short lived object to provide simplified alias syntax. 00057 * Only the friend function alias is allowed to create 00058 * such a object. The proxy calls the appropriate member 00059 * alias_xyz() which have to use temporaries to avoid 00060 * overlapping memory regions. 00061 * \sa alias 00062 * \sa Some Notes \ref alias 00063 * \note Thanks to ublas-dev group, where the principle idea 00064 * comes from. 00065 */ 00066 template<class E> 00067 class AliasProxy 00068 { 00069 AliasProxy(const AliasProxy&); 00070 AliasProxy& operator=(const AliasProxy&); 00071 00072 friend AliasProxy<E> alias<>(E& expr); 00073 00074 public: 00075 AliasProxy(E& expr) : m_expr(expr) { } 00076 00077 00078 template<class E2> 00079 E& operator=(const E2& expr) { 00080 return m_expr.alias_assign(expr); 00081 } 00082 00083 template<class E2> 00084 E& operator+=(const E2& expr) { 00085 return m_expr.alias_add_eq(expr); 00086 } 00087 00088 template<class E2> 00089 E& operator-=(const E2& expr) { 00090 return m_expr.alias_sub_eq(expr); 00091 } 00092 00093 template<class E2> 00094 E& operator*=(const E2& expr) { 00095 return m_expr.alias_mul_eq(expr); 00096 } 00097 00098 template<class E2> 00099 E& operator/=(const E2& expr) { 00100 return m_expr.alias_div_eq(expr); 00101 } 00102 00103 private: 00104 E& m_expr; 00105 }; 00106 00107 00108 #if 0 00109 namespace element_wise { 00110 // \todo to write 00111 template<class E, class E2> 00112 E& operator/=(AliasProxy<E>& proxy, const E2& rhs) { 00113 return proxy.div_upd(rhs); 00114 } 00115 00116 } 00117 #endif 00118 00119 00120 } // namespace tvmet 00121 00122 00123 #endif /* TVMET_ALIAS_PROXY_H */ 00124 00125 // Local Variables: 00126 // mode:C++ 00127 // tab-width:8 00128 // End:
Generated on Tue Jul 12 2022 19:00:11 by 1.7.2