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
VectorUnaryFunctions.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: VectorUnaryFunctions.h,v 1.11 2007-06-23 15:59:00 opetzold Exp $ 00022 */ 00023 00024 #ifndef TVMET_XPR_VECTOR_UNARY_FUNCTIONS_H 00025 #define TVMET_XPR_VECTOR_UNARY_FUNCTIONS_H 00026 00027 namespace tvmet { 00028 00029 00030 /********************************************************* 00031 * PART I: DECLARATION 00032 *********************************************************/ 00033 00034 /* 00035 * unary_function(XprVector<E, Sz>) 00036 */ 00037 #define TVMET_DECLARE_MACRO(NAME) \ 00038 template<class E, std::size_t Sz> \ 00039 inline \ 00040 XprVector< \ 00041 XprUnOp< \ 00042 Fcnl_##NAME<typename E::value_type>, \ 00043 XprVector<E, Sz> \ 00044 >, \ 00045 Sz \ 00046 > \ 00047 NAME(const XprVector<E, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE; 00048 00049 TVMET_DECLARE_MACRO(abs) 00050 TVMET_DECLARE_MACRO(cbrt) 00051 TVMET_DECLARE_MACRO(ceil) 00052 TVMET_DECLARE_MACRO(floor) 00053 TVMET_DECLARE_MACRO(rint) 00054 TVMET_DECLARE_MACRO(sin) 00055 TVMET_DECLARE_MACRO(cos) 00056 TVMET_DECLARE_MACRO(tan) 00057 TVMET_DECLARE_MACRO(sinh) 00058 TVMET_DECLARE_MACRO(cosh) 00059 TVMET_DECLARE_MACRO(tanh) 00060 TVMET_DECLARE_MACRO(asin) 00061 TVMET_DECLARE_MACRO(acos) 00062 TVMET_DECLARE_MACRO(atan) 00063 TVMET_DECLARE_MACRO(exp) 00064 TVMET_DECLARE_MACRO(log) 00065 TVMET_DECLARE_MACRO(log10) 00066 TVMET_DECLARE_MACRO(sqrt) 00067 00068 #if defined(TVMET_HAVE_IEEE_MATH) 00069 TVMET_DECLARE_MACRO(asinh) 00070 TVMET_DECLARE_MACRO(acosh) 00071 TVMET_DECLARE_MACRO(atanh) 00072 TVMET_DECLARE_MACRO(expm1) 00073 TVMET_DECLARE_MACRO(log1p) 00074 TVMET_DECLARE_MACRO(erf) 00075 TVMET_DECLARE_MACRO(erfc) 00076 TVMET_DECLARE_MACRO(j0) 00077 TVMET_DECLARE_MACRO(j1) 00078 TVMET_DECLARE_MACRO(y0) 00079 TVMET_DECLARE_MACRO(y1) 00080 TVMET_DECLARE_MACRO(lgamma) 00081 /** \todo isnan etc. - default return is only an int! */ 00082 00083 TVMET_DECLARE_MACRO(finite) 00084 #endif // defined(TVMET_HAVE_IEEE_MATH) 00085 00086 #undef TVMET_DECLARE_MACRO 00087 00088 00089 /********************************************************* 00090 * PART II: IMPLEMENTATION 00091 *********************************************************/ 00092 00093 00094 /* 00095 * unary_function(XprVector<E, Sz>) 00096 */ 00097 #define TVMET_IMPLEMENT_MACRO(NAME) \ 00098 template<class E, std::size_t Sz> \ 00099 inline \ 00100 XprVector< \ 00101 XprUnOp< \ 00102 Fcnl_##NAME<typename E::value_type>, \ 00103 XprVector<E, Sz> \ 00104 >, \ 00105 Sz \ 00106 > \ 00107 NAME(const XprVector<E, Sz>& rhs) { \ 00108 typedef XprUnOp< \ 00109 Fcnl_##NAME<typename E::value_type>, \ 00110 XprVector<E, Sz> \ 00111 > expr_type; \ 00112 return XprVector<expr_type, Sz>(expr_type(rhs)); \ 00113 } 00114 00115 TVMET_IMPLEMENT_MACRO(abs) 00116 TVMET_IMPLEMENT_MACRO(cbrt) 00117 TVMET_IMPLEMENT_MACRO(ceil) 00118 TVMET_IMPLEMENT_MACRO(floor) 00119 TVMET_IMPLEMENT_MACRO(rint) 00120 TVMET_IMPLEMENT_MACRO(sin) 00121 TVMET_IMPLEMENT_MACRO(cos) 00122 TVMET_IMPLEMENT_MACRO(tan) 00123 TVMET_IMPLEMENT_MACRO(sinh) 00124 TVMET_IMPLEMENT_MACRO(cosh) 00125 TVMET_IMPLEMENT_MACRO(tanh) 00126 TVMET_IMPLEMENT_MACRO(asin) 00127 TVMET_IMPLEMENT_MACRO(acos) 00128 TVMET_IMPLEMENT_MACRO(atan) 00129 TVMET_IMPLEMENT_MACRO(exp) 00130 TVMET_IMPLEMENT_MACRO(log) 00131 TVMET_IMPLEMENT_MACRO(log10) 00132 TVMET_IMPLEMENT_MACRO(sqrt) 00133 00134 #if defined(TVMET_HAVE_IEEE_MATH) 00135 TVMET_IMPLEMENT_MACRO(asinh) 00136 TVMET_IMPLEMENT_MACRO(acosh) 00137 TVMET_IMPLEMENT_MACRO(atanh) 00138 TVMET_IMPLEMENT_MACRO(expm1) 00139 TVMET_IMPLEMENT_MACRO(log1p) 00140 TVMET_IMPLEMENT_MACRO(erf) 00141 TVMET_IMPLEMENT_MACRO(erfc) 00142 TVMET_IMPLEMENT_MACRO(j0) 00143 TVMET_IMPLEMENT_MACRO(j1) 00144 TVMET_IMPLEMENT_MACRO(y0) 00145 TVMET_IMPLEMENT_MACRO(y1) 00146 TVMET_IMPLEMENT_MACRO(lgamma) 00147 /** \todo isnan etc. - default return is only an int! */ 00148 00149 TVMET_IMPLEMENT_MACRO(finite) 00150 #endif // defined(TVMET_HAVE_IEEE_MATH) 00151 00152 #undef TVMET_IMPLEMENT_MACRO 00153 00154 00155 00156 } // namespace tvmet 00157 00158 #endif // TVMET_XPR_VECTOR_FUNCTIONS_H 00159 00160 // Local Variables: 00161 // mode:C++ 00162 // tab-width:8 00163 // End:
Generated on Tue Jul 12 2022 19:00:12 by 1.7.2