Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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.13 2007-06-23 15:58:58 opetzold Exp $ 00022 */ 00023 00024 #ifndef TVMET_VECTOR_UNARY_FUNCTIONS_H 00025 #define TVMET_VECTOR_UNARY_FUNCTIONS_H 00026 00027 namespace tvmet { 00028 00029 00030 /********************************************************* 00031 * PART I: DECLARATION 00032 *********************************************************/ 00033 00034 /* 00035 * unary_function(Vector<T, Sz>) 00036 */ 00037 #define TVMET_DECLARE_MACRO(NAME) \ 00038 template<class T, std::size_t Sz> \ 00039 XprVector< \ 00040 XprUnOp< \ 00041 Fcnl_##NAME<T>, \ 00042 VectorConstReference<T, Sz> \ 00043 >, \ 00044 Sz \ 00045 > \ 00046 NAME(const Vector<T, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE; 00047 00048 TVMET_DECLARE_MACRO(abs) 00049 TVMET_DECLARE_MACRO(cbrt) 00050 TVMET_DECLARE_MACRO(ceil) 00051 TVMET_DECLARE_MACRO(floor) 00052 TVMET_DECLARE_MACRO(rint) 00053 TVMET_DECLARE_MACRO(sin) 00054 TVMET_DECLARE_MACRO(cos) 00055 TVMET_DECLARE_MACRO(tan) 00056 TVMET_DECLARE_MACRO(sinh) 00057 TVMET_DECLARE_MACRO(cosh) 00058 TVMET_DECLARE_MACRO(tanh) 00059 TVMET_DECLARE_MACRO(asin) 00060 TVMET_DECLARE_MACRO(acos) 00061 TVMET_DECLARE_MACRO(atan) 00062 TVMET_DECLARE_MACRO(exp) 00063 TVMET_DECLARE_MACRO(log) 00064 TVMET_DECLARE_MACRO(log10) 00065 TVMET_DECLARE_MACRO(sqrt) 00066 00067 #if defined(TVMET_HAVE_IEEE_MATH) 00068 TVMET_DECLARE_MACRO(asinh) 00069 TVMET_DECLARE_MACRO(acosh) 00070 TVMET_DECLARE_MACRO(atanh) 00071 TVMET_DECLARE_MACRO(expm1) 00072 TVMET_DECLARE_MACRO(log1p) 00073 TVMET_DECLARE_MACRO(erf) 00074 TVMET_DECLARE_MACRO(erfc) 00075 TVMET_DECLARE_MACRO(j0) 00076 TVMET_DECLARE_MACRO(j1) 00077 TVMET_DECLARE_MACRO(y0) 00078 TVMET_DECLARE_MACRO(y1) 00079 TVMET_DECLARE_MACRO(lgamma) 00080 /** \todo isnan etc. - default return is only an int! */ 00081 00082 TVMET_DECLARE_MACRO(finite) 00083 #endif // defined(TVMET_HAVE_IEEE_MATH) 00084 00085 #undef TVMET_DECLARE_MACRO 00086 00087 00088 /* 00089 * unary_function(Vector<std::complex<T>, Sz>) 00090 */ 00091 #if defined(TVMET_HAVE_COMPLEX) 00092 #define TVMET_DECLARE_MACRO(NAME) \ 00093 template<class T, std::size_t Sz> \ 00094 XprVector< \ 00095 XprUnOp< \ 00096 Fcnl_##NAME< std::complex<T> >, \ 00097 VectorConstReference<std::complex<T>, Sz> \ 00098 >, \ 00099 Sz \ 00100 > \ 00101 NAME(const Vector<std::complex<T>, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE; 00102 00103 TVMET_DECLARE_MACRO(real) 00104 TVMET_DECLARE_MACRO(imag) 00105 TVMET_DECLARE_MACRO(arg) 00106 TVMET_DECLARE_MACRO(norm) 00107 TVMET_DECLARE_MACRO(conj) 00108 00109 #undef TVMET_DECLARE_MACRO 00110 00111 #endif // defined(TVMET_HAVE_COMPLEX) 00112 00113 00114 /********************************************************* 00115 * PART II: IMPLEMENTATION 00116 *********************************************************/ 00117 00118 00119 /* 00120 * unary_function(Vector<T, Sz>) 00121 */ 00122 #define TVMET_IMPLEMENT_MACRO(NAME) \ 00123 template<class T, std::size_t Sz> \ 00124 inline \ 00125 XprVector< \ 00126 XprUnOp< \ 00127 Fcnl_##NAME<T>, \ 00128 VectorConstReference<T, Sz> \ 00129 >, \ 00130 Sz \ 00131 > \ 00132 NAME(const Vector<T, Sz>& rhs) { \ 00133 typedef XprUnOp< \ 00134 Fcnl_##NAME<T>, \ 00135 VectorConstReference<T, Sz> \ 00136 > expr_type; \ 00137 return XprVector<expr_type, Sz>(expr_type(rhs.const_ref())); \ 00138 } 00139 00140 TVMET_IMPLEMENT_MACRO(abs) 00141 TVMET_IMPLEMENT_MACRO(cbrt) 00142 TVMET_IMPLEMENT_MACRO(ceil) 00143 TVMET_IMPLEMENT_MACRO(floor) 00144 TVMET_IMPLEMENT_MACRO(rint) 00145 TVMET_IMPLEMENT_MACRO(sin) 00146 TVMET_IMPLEMENT_MACRO(cos) 00147 TVMET_IMPLEMENT_MACRO(tan) 00148 TVMET_IMPLEMENT_MACRO(sinh) 00149 TVMET_IMPLEMENT_MACRO(cosh) 00150 TVMET_IMPLEMENT_MACRO(tanh) 00151 TVMET_IMPLEMENT_MACRO(asin) 00152 TVMET_IMPLEMENT_MACRO(acos) 00153 TVMET_IMPLEMENT_MACRO(atan) 00154 TVMET_IMPLEMENT_MACRO(exp) 00155 TVMET_IMPLEMENT_MACRO(log) 00156 TVMET_IMPLEMENT_MACRO(log10) 00157 TVMET_IMPLEMENT_MACRO(sqrt) 00158 00159 #if defined(TVMET_HAVE_IEEE_MATH) 00160 TVMET_IMPLEMENT_MACRO(asinh) 00161 TVMET_IMPLEMENT_MACRO(acosh) 00162 TVMET_IMPLEMENT_MACRO(atanh) 00163 TVMET_IMPLEMENT_MACRO(expm1) 00164 TVMET_IMPLEMENT_MACRO(log1p) 00165 TVMET_IMPLEMENT_MACRO(erf) 00166 TVMET_IMPLEMENT_MACRO(erfc) 00167 TVMET_IMPLEMENT_MACRO(j0) 00168 TVMET_IMPLEMENT_MACRO(j1) 00169 TVMET_IMPLEMENT_MACRO(y0) 00170 TVMET_IMPLEMENT_MACRO(y1) 00171 TVMET_IMPLEMENT_MACRO(lgamma) 00172 /** \todo isnan etc. - default return is only an int! */ 00173 00174 TVMET_IMPLEMENT_MACRO(finite) 00175 #endif // defined(TVMET_HAVE_IEEE_MATH) 00176 00177 #undef TVMET_IMPLEMENT_MACRO 00178 00179 00180 /* 00181 * unary_function(Vector<std::complex<T>, Sz>) 00182 */ 00183 #if defined(TVMET_HAVE_COMPLEX) 00184 #define TVMET_IMPLEMENT_MACRO(NAME) \ 00185 template<class T, std::size_t Sz> \ 00186 inline \ 00187 XprVector< \ 00188 XprUnOp< \ 00189 Fcnl_##NAME< std::complex<T> >, \ 00190 VectorConstReference<std::complex<T>, Sz> \ 00191 >, \ 00192 Sz \ 00193 > \ 00194 NAME(const Vector<std::complex<T>, Sz>& rhs) { \ 00195 typedef XprUnOp< \ 00196 Fcnl_##NAME< std::complex<T> >, \ 00197 VectorConstReference<std::complex<T>, Sz> \ 00198 > expr_type; \ 00199 return XprVector<expr_type, Sz>(expr_type(rhs.const_ref())); \ 00200 } 00201 00202 TVMET_IMPLEMENT_MACRO(real) 00203 TVMET_IMPLEMENT_MACRO(imag) 00204 TVMET_IMPLEMENT_MACRO(arg) 00205 TVMET_IMPLEMENT_MACRO(norm) 00206 TVMET_IMPLEMENT_MACRO(conj) 00207 00208 #undef TVMET_IMPLEMENT_MACRO 00209 00210 #endif // defined(TVMET_HAVE_COMPLEX) 00211 00212 00213 } // namespace tvmet 00214 00215 #endif // TVMET_VECTOR_UNARY_FUNCTIONS_H 00216 00217 // Local Variables: 00218 // mode:C++ 00219 // tab-width:8 00220 // End:
Generated on Tue Jul 12 2022 19:50:03 by
1.7.2