Oskar Weigl
/
Eurobot2013
We are going to win! wohoo
tvmet/UnaryFunctionals.h@9:08552997b544, 2012-11-14 (annotated)
- Committer:
- madcowswe
- Date:
- Wed Nov 14 17:15:53 2012 +0000
- Revision:
- 9:08552997b544
- Parent:
- 1:6799c07fe510
Added an important comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sv | 1:6799c07fe510 | 1 | /* |
sv | 1:6799c07fe510 | 2 | * Tiny Vector Matrix Library |
sv | 1:6799c07fe510 | 3 | * Dense Vector Matrix Libary of Tiny size using Expression Templates |
sv | 1:6799c07fe510 | 4 | * |
sv | 1:6799c07fe510 | 5 | * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net> |
sv | 1:6799c07fe510 | 6 | * |
sv | 1:6799c07fe510 | 7 | * This library is free software; you can redistribute it and/or |
sv | 1:6799c07fe510 | 8 | * modify it under the terms of the GNU Lesser General Public |
sv | 1:6799c07fe510 | 9 | * License as published by the Free Software Foundation; either |
sv | 1:6799c07fe510 | 10 | * version 2.1 of the License, or (at your option) any later version. |
sv | 1:6799c07fe510 | 11 | * |
sv | 1:6799c07fe510 | 12 | * This library is distributed in the hope that it will be useful, |
sv | 1:6799c07fe510 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
sv | 1:6799c07fe510 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
sv | 1:6799c07fe510 | 15 | * Lesser General Public License for more details. |
sv | 1:6799c07fe510 | 16 | * |
sv | 1:6799c07fe510 | 17 | * You should have received a copy of the GNU Lesser General Public |
sv | 1:6799c07fe510 | 18 | * License along with this library; if not, write to the Free Software |
sv | 1:6799c07fe510 | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
sv | 1:6799c07fe510 | 20 | * |
sv | 1:6799c07fe510 | 21 | * $Id: UnaryFunctionals.h,v 1.24 2007-06-23 15:58:58 opetzold Exp $ |
sv | 1:6799c07fe510 | 22 | */ |
sv | 1:6799c07fe510 | 23 | |
sv | 1:6799c07fe510 | 24 | #ifndef TVMET_UNARY_FUNCTIONAL_H |
sv | 1:6799c07fe510 | 25 | #define TVMET_UNARY_FUNCTIONAL_H |
sv | 1:6799c07fe510 | 26 | |
sv | 1:6799c07fe510 | 27 | namespace tvmet { |
sv | 1:6799c07fe510 | 28 | |
sv | 1:6799c07fe510 | 29 | /** \class Fcnl_compl UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 30 | /** \class Fcnl_neg UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 31 | /** \class Fcnl_not UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 32 | #define TVMET_IMPLEMENT_MACRO(NAME, OP) \ |
sv | 1:6799c07fe510 | 33 | template <class T> \ |
sv | 1:6799c07fe510 | 34 | struct Fcnl_##NAME : public UnaryFunctional { \ |
sv | 1:6799c07fe510 | 35 | typedef T value_type; \ |
sv | 1:6799c07fe510 | 36 | \ |
sv | 1:6799c07fe510 | 37 | static inline \ |
sv | 1:6799c07fe510 | 38 | value_type apply_on(value_type rhs) { \ |
sv | 1:6799c07fe510 | 39 | return OP rhs; \ |
sv | 1:6799c07fe510 | 40 | } \ |
sv | 1:6799c07fe510 | 41 | \ |
sv | 1:6799c07fe510 | 42 | static \ |
sv | 1:6799c07fe510 | 43 | void print_xpr(std::ostream& os, std::size_t l=0) { \ |
sv | 1:6799c07fe510 | 44 | os << IndentLevel(l) << "Fcnl_" << #NAME << "<T=" \ |
sv | 1:6799c07fe510 | 45 | << typeid(T).name() << ">," \ |
sv | 1:6799c07fe510 | 46 | << std::endl; \ |
sv | 1:6799c07fe510 | 47 | } \ |
sv | 1:6799c07fe510 | 48 | }; |
sv | 1:6799c07fe510 | 49 | |
sv | 1:6799c07fe510 | 50 | TVMET_IMPLEMENT_MACRO(compl, ~) |
sv | 1:6799c07fe510 | 51 | TVMET_IMPLEMENT_MACRO(neg, -) |
sv | 1:6799c07fe510 | 52 | TVMET_IMPLEMENT_MACRO(not, !) |
sv | 1:6799c07fe510 | 53 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 54 | |
sv | 1:6799c07fe510 | 55 | |
sv | 1:6799c07fe510 | 56 | /** \class Fcnl_abs UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 57 | /** \class Fcnl_ceil UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 58 | /** \class Fcnl_floor UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 59 | /** \class Fcnl_sin UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 60 | /** \class Fcnl_cos UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 61 | /** \class Fcnl_tan UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 62 | /** \class Fcnl_sinh UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 63 | /** \class Fcnl_cosh UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 64 | /** \class Fcnl_tanh UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 65 | /** \class Fcnl_asin UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 66 | /** \class Fcnl_acos UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 67 | /** \class Fcnl_atan UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 68 | /** \class Fcnl_exp UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 69 | /** \class Fcnl_log UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 70 | /** \class Fcnl_log10 UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 71 | /** \class Fcnl_sqrt UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 72 | #define TVMET_IMPLEMENT_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 73 | template <class T> \ |
sv | 1:6799c07fe510 | 74 | struct Fcnl_##NAME : public UnaryFunctional { \ |
sv | 1:6799c07fe510 | 75 | typedef T value_type; \ |
sv | 1:6799c07fe510 | 76 | \ |
sv | 1:6799c07fe510 | 77 | static inline \ |
sv | 1:6799c07fe510 | 78 | value_type apply_on(value_type rhs) { \ |
sv | 1:6799c07fe510 | 79 | return TVMET_STD_SCOPE(NAME)(rhs); \ |
sv | 1:6799c07fe510 | 80 | } \ |
sv | 1:6799c07fe510 | 81 | \ |
sv | 1:6799c07fe510 | 82 | static \ |
sv | 1:6799c07fe510 | 83 | void print_xpr(std::ostream& os, std::size_t l=0) { \ |
sv | 1:6799c07fe510 | 84 | os << IndentLevel(l) << "Fcnl_" << #NAME << "<T=" \ |
sv | 1:6799c07fe510 | 85 | << typeid(value_type).name() << ">," \ |
sv | 1:6799c07fe510 | 86 | << std::endl; \ |
sv | 1:6799c07fe510 | 87 | } \ |
sv | 1:6799c07fe510 | 88 | }; |
sv | 1:6799c07fe510 | 89 | |
sv | 1:6799c07fe510 | 90 | TVMET_IMPLEMENT_MACRO(abs) // specialized later, see below |
sv | 1:6799c07fe510 | 91 | TVMET_IMPLEMENT_MACRO(ceil) |
sv | 1:6799c07fe510 | 92 | TVMET_IMPLEMENT_MACRO(floor) |
sv | 1:6799c07fe510 | 93 | TVMET_IMPLEMENT_MACRO(sin) |
sv | 1:6799c07fe510 | 94 | TVMET_IMPLEMENT_MACRO(cos) |
sv | 1:6799c07fe510 | 95 | TVMET_IMPLEMENT_MACRO(tan) |
sv | 1:6799c07fe510 | 96 | TVMET_IMPLEMENT_MACRO(sinh) |
sv | 1:6799c07fe510 | 97 | TVMET_IMPLEMENT_MACRO(cosh) |
sv | 1:6799c07fe510 | 98 | TVMET_IMPLEMENT_MACRO(tanh) |
sv | 1:6799c07fe510 | 99 | TVMET_IMPLEMENT_MACRO(asin) |
sv | 1:6799c07fe510 | 100 | TVMET_IMPLEMENT_MACRO(acos) |
sv | 1:6799c07fe510 | 101 | TVMET_IMPLEMENT_MACRO(atan) |
sv | 1:6799c07fe510 | 102 | TVMET_IMPLEMENT_MACRO(exp) |
sv | 1:6799c07fe510 | 103 | TVMET_IMPLEMENT_MACRO(log) |
sv | 1:6799c07fe510 | 104 | TVMET_IMPLEMENT_MACRO(log10) |
sv | 1:6799c07fe510 | 105 | TVMET_IMPLEMENT_MACRO(sqrt) |
sv | 1:6799c07fe510 | 106 | |
sv | 1:6799c07fe510 | 107 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 108 | |
sv | 1:6799c07fe510 | 109 | |
sv | 1:6799c07fe510 | 110 | /** \class Fcnl_cbrt UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 111 | /** \class Fcnl_rint UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 112 | #define TVMET_IMPLEMENT_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 113 | template <class T> \ |
sv | 1:6799c07fe510 | 114 | struct Fcnl_##NAME : public UnaryFunctional { \ |
sv | 1:6799c07fe510 | 115 | typedef T value_type; \ |
sv | 1:6799c07fe510 | 116 | \ |
sv | 1:6799c07fe510 | 117 | static inline \ |
sv | 1:6799c07fe510 | 118 | value_type apply_on(value_type rhs) { \ |
sv | 1:6799c07fe510 | 119 | return TVMET_GLOBAL_SCOPE(NAME)(rhs); \ |
sv | 1:6799c07fe510 | 120 | } \ |
sv | 1:6799c07fe510 | 121 | \ |
sv | 1:6799c07fe510 | 122 | static \ |
sv | 1:6799c07fe510 | 123 | void print_xpr(std::ostream& os, std::size_t l=0) { \ |
sv | 1:6799c07fe510 | 124 | os << IndentLevel(l) << "Fcnl_" << #NAME << "<T=" \ |
sv | 1:6799c07fe510 | 125 | << typeid(value_type).name() << ">," \ |
sv | 1:6799c07fe510 | 126 | << std::endl; \ |
sv | 1:6799c07fe510 | 127 | } \ |
sv | 1:6799c07fe510 | 128 | }; |
sv | 1:6799c07fe510 | 129 | |
sv | 1:6799c07fe510 | 130 | TVMET_IMPLEMENT_MACRO(cbrt) |
sv | 1:6799c07fe510 | 131 | TVMET_IMPLEMENT_MACRO(rint) |
sv | 1:6799c07fe510 | 132 | |
sv | 1:6799c07fe510 | 133 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 134 | |
sv | 1:6799c07fe510 | 135 | |
sv | 1:6799c07fe510 | 136 | #if defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 137 | |
sv | 1:6799c07fe510 | 138 | /** \class Fcnl_asinh UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 139 | /** \class Fcnl_acosh UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 140 | /** \class Fcnl_atanh UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 141 | /** \class Fcnl_expm1 UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 142 | /** \class Fcnl_log1p UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 143 | /** \class Fcnl_erf UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 144 | /** \class Fcnl_erfc UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 145 | /** \class Fcnl_j0 UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 146 | /** \class Fcnl_j1 UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 147 | /** \class Fcnl_y0 UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 148 | /** \class Fcnl_y1 UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 149 | /** \class Fcnl_lgamma UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 150 | #define TVMET_IMPLEMENT_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 151 | template <class T> \ |
sv | 1:6799c07fe510 | 152 | struct Fcnl_##NAME : public UnaryFunctional { \ |
sv | 1:6799c07fe510 | 153 | typedef T value_type; \ |
sv | 1:6799c07fe510 | 154 | \ |
sv | 1:6799c07fe510 | 155 | static inline \ |
sv | 1:6799c07fe510 | 156 | value_type apply_on(value_type rhs) { \ |
sv | 1:6799c07fe510 | 157 | return TVMET_GLOBAL_SCOPE(NAME)(rhs); \ |
sv | 1:6799c07fe510 | 158 | } \ |
sv | 1:6799c07fe510 | 159 | \ |
sv | 1:6799c07fe510 | 160 | static \ |
sv | 1:6799c07fe510 | 161 | void print_xpr(std::ostream& os, std::size_t l=0) { \ |
sv | 1:6799c07fe510 | 162 | os << IndentLevel(l) << "Fcnl_" << #NAME << "<T=" \ |
sv | 1:6799c07fe510 | 163 | << typeid(value_type).name() << ">," \ |
sv | 1:6799c07fe510 | 164 | << std::endl; \ |
sv | 1:6799c07fe510 | 165 | } \ |
sv | 1:6799c07fe510 | 166 | }; |
sv | 1:6799c07fe510 | 167 | |
sv | 1:6799c07fe510 | 168 | TVMET_IMPLEMENT_MACRO(asinh) |
sv | 1:6799c07fe510 | 169 | TVMET_IMPLEMENT_MACRO(acosh) |
sv | 1:6799c07fe510 | 170 | TVMET_IMPLEMENT_MACRO(atanh) |
sv | 1:6799c07fe510 | 171 | TVMET_IMPLEMENT_MACRO(expm1) |
sv | 1:6799c07fe510 | 172 | TVMET_IMPLEMENT_MACRO(log1p) |
sv | 1:6799c07fe510 | 173 | TVMET_IMPLEMENT_MACRO(erf) |
sv | 1:6799c07fe510 | 174 | TVMET_IMPLEMENT_MACRO(erfc) |
sv | 1:6799c07fe510 | 175 | TVMET_IMPLEMENT_MACRO(j0) |
sv | 1:6799c07fe510 | 176 | TVMET_IMPLEMENT_MACRO(j1) |
sv | 1:6799c07fe510 | 177 | TVMET_IMPLEMENT_MACRO(y0) |
sv | 1:6799c07fe510 | 178 | TVMET_IMPLEMENT_MACRO(y1) |
sv | 1:6799c07fe510 | 179 | TVMET_IMPLEMENT_MACRO(lgamma) |
sv | 1:6799c07fe510 | 180 | |
sv | 1:6799c07fe510 | 181 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 182 | |
sv | 1:6799c07fe510 | 183 | #endif // defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 184 | |
sv | 1:6799c07fe510 | 185 | |
sv | 1:6799c07fe510 | 186 | /** \class Fcnl_abs<long int> UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 187 | /** \class Fcnl_abs<long long int> UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 188 | /** \class Fcnl_abs<float> UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 189 | /** \class Fcnl_abs<double> UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 190 | /** \class Fcnl_abs<long double> UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 191 | #define TVMET_IMPLEMENT_MACRO(NAME, POD) \ |
sv | 1:6799c07fe510 | 192 | template <class T> struct Fcnl_##NAME; \ |
sv | 1:6799c07fe510 | 193 | template <> \ |
sv | 1:6799c07fe510 | 194 | struct Fcnl_##NAME< POD > : public UnaryFunctional { \ |
sv | 1:6799c07fe510 | 195 | typedef POD value_type; \ |
sv | 1:6799c07fe510 | 196 | \ |
sv | 1:6799c07fe510 | 197 | static inline \ |
sv | 1:6799c07fe510 | 198 | value_type apply_on(value_type rhs) { \ |
sv | 1:6799c07fe510 | 199 | return TVMET_STD_SCOPE(NAME)(rhs); \ |
sv | 1:6799c07fe510 | 200 | } \ |
sv | 1:6799c07fe510 | 201 | \ |
sv | 1:6799c07fe510 | 202 | static \ |
sv | 1:6799c07fe510 | 203 | void print_xpr(std::ostream& os, std::size_t l=0) { \ |
sv | 1:6799c07fe510 | 204 | os << IndentLevel(l) << "Fcnl_" << #NAME << "<T=" \ |
sv | 1:6799c07fe510 | 205 | << typeid(value_type).name() << ">," \ |
sv | 1:6799c07fe510 | 206 | << std::endl; \ |
sv | 1:6799c07fe510 | 207 | } \ |
sv | 1:6799c07fe510 | 208 | }; |
sv | 1:6799c07fe510 | 209 | |
sv | 1:6799c07fe510 | 210 | TVMET_IMPLEMENT_MACRO(labs, long int) |
sv | 1:6799c07fe510 | 211 | |
sv | 1:6799c07fe510 | 212 | #if defined(TVMET_HAVE_LONG_LONG) |
sv | 1:6799c07fe510 | 213 | TVMET_IMPLEMENT_MACRO(labs, long long int) |
sv | 1:6799c07fe510 | 214 | #endif |
sv | 1:6799c07fe510 | 215 | |
sv | 1:6799c07fe510 | 216 | TVMET_IMPLEMENT_MACRO(fabs, float) |
sv | 1:6799c07fe510 | 217 | TVMET_IMPLEMENT_MACRO(fabs, double) |
sv | 1:6799c07fe510 | 218 | |
sv | 1:6799c07fe510 | 219 | #if defined(TVMET_HAVE_LONG_DOUBLE) |
sv | 1:6799c07fe510 | 220 | TVMET_IMPLEMENT_MACRO(fabs, long double) |
sv | 1:6799c07fe510 | 221 | #endif |
sv | 1:6799c07fe510 | 222 | |
sv | 1:6799c07fe510 | 223 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 224 | |
sv | 1:6799c07fe510 | 225 | |
sv | 1:6799c07fe510 | 226 | /* |
sv | 1:6799c07fe510 | 227 | * complex support |
sv | 1:6799c07fe510 | 228 | */ |
sv | 1:6799c07fe510 | 229 | |
sv | 1:6799c07fe510 | 230 | #if defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 231 | /** |
sv | 1:6799c07fe510 | 232 | * \class Fcnl_abs< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" |
sv | 1:6799c07fe510 | 233 | */ |
sv | 1:6799c07fe510 | 234 | template <class T> |
sv | 1:6799c07fe510 | 235 | struct Fcnl_abs< std::complex<T> > : public UnaryFunctional { |
sv | 1:6799c07fe510 | 236 | typedef T value_type; |
sv | 1:6799c07fe510 | 237 | |
sv | 1:6799c07fe510 | 238 | static inline |
sv | 1:6799c07fe510 | 239 | value_type apply_on(const std::complex<T>& rhs) { |
sv | 1:6799c07fe510 | 240 | return std::abs(rhs); |
sv | 1:6799c07fe510 | 241 | } |
sv | 1:6799c07fe510 | 242 | |
sv | 1:6799c07fe510 | 243 | static |
sv | 1:6799c07fe510 | 244 | void print_xpr(std::ostream& os, std::size_t l=0) { |
sv | 1:6799c07fe510 | 245 | os << IndentLevel(l) << "Fcnl_abs<T=" |
sv | 1:6799c07fe510 | 246 | << typeid(std::complex<T>).name() << ">," |
sv | 1:6799c07fe510 | 247 | << std::endl; |
sv | 1:6799c07fe510 | 248 | } |
sv | 1:6799c07fe510 | 249 | }; |
sv | 1:6799c07fe510 | 250 | |
sv | 1:6799c07fe510 | 251 | |
sv | 1:6799c07fe510 | 252 | /** |
sv | 1:6799c07fe510 | 253 | * \class Fcnl_conj< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" |
sv | 1:6799c07fe510 | 254 | * \brief %Functional for conj. |
sv | 1:6799c07fe510 | 255 | */ |
sv | 1:6799c07fe510 | 256 | template <class T> struct Fcnl_conj : public UnaryFunctional { }; |
sv | 1:6799c07fe510 | 257 | |
sv | 1:6799c07fe510 | 258 | |
sv | 1:6799c07fe510 | 259 | /** \class Fcnl_conj< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 260 | template <class T> |
sv | 1:6799c07fe510 | 261 | struct Fcnl_conj< std::complex<T> > : public UnaryFunctional { |
sv | 1:6799c07fe510 | 262 | typedef std::complex<T> value_type; |
sv | 1:6799c07fe510 | 263 | |
sv | 1:6799c07fe510 | 264 | static inline |
sv | 1:6799c07fe510 | 265 | value_type apply_on(const std::complex<T>& rhs) { |
sv | 1:6799c07fe510 | 266 | return std::conj(rhs); |
sv | 1:6799c07fe510 | 267 | } |
sv | 1:6799c07fe510 | 268 | |
sv | 1:6799c07fe510 | 269 | static |
sv | 1:6799c07fe510 | 270 | void print_xpr(std::ostream& os, std::size_t l=0) { |
sv | 1:6799c07fe510 | 271 | os << IndentLevel(l) << "Fcnl_conj<T=" |
sv | 1:6799c07fe510 | 272 | << typeid(std::complex<T>).name() << ">," |
sv | 1:6799c07fe510 | 273 | << std::endl; |
sv | 1:6799c07fe510 | 274 | } |
sv | 1:6799c07fe510 | 275 | }; |
sv | 1:6799c07fe510 | 276 | |
sv | 1:6799c07fe510 | 277 | |
sv | 1:6799c07fe510 | 278 | /** \class Fcnl_real< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 279 | /** \class Fcnl_imag< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 280 | /** \class Fcnl_arg< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 281 | /** \class Fcnl_norm< std::complex<T> > UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 282 | #define TVMET_IMPLEMENT_MACRO(NAME) \ |
sv | 1:6799c07fe510 | 283 | template <class T> struct Fcnl_##NAME; \ |
sv | 1:6799c07fe510 | 284 | template <class T> \ |
sv | 1:6799c07fe510 | 285 | struct Fcnl_##NAME< std::complex<T> > : public UnaryFunctional { \ |
sv | 1:6799c07fe510 | 286 | typedef T value_type; \ |
sv | 1:6799c07fe510 | 287 | \ |
sv | 1:6799c07fe510 | 288 | static inline \ |
sv | 1:6799c07fe510 | 289 | value_type apply_on(const std::complex<T>& rhs) { \ |
sv | 1:6799c07fe510 | 290 | return TVMET_STD_SCOPE(NAME)(rhs); \ |
sv | 1:6799c07fe510 | 291 | } \ |
sv | 1:6799c07fe510 | 292 | \ |
sv | 1:6799c07fe510 | 293 | static \ |
sv | 1:6799c07fe510 | 294 | void print_xpr(std::ostream& os, std::size_t l=0) { \ |
sv | 1:6799c07fe510 | 295 | os << IndentLevel(l) << "Fcnl_" << #NAME << "<T=" \ |
sv | 1:6799c07fe510 | 296 | << typeid(std::complex<T>).name() << ">," \ |
sv | 1:6799c07fe510 | 297 | << std::endl; \ |
sv | 1:6799c07fe510 | 298 | } \ |
sv | 1:6799c07fe510 | 299 | }; |
sv | 1:6799c07fe510 | 300 | |
sv | 1:6799c07fe510 | 301 | TVMET_IMPLEMENT_MACRO(real) |
sv | 1:6799c07fe510 | 302 | TVMET_IMPLEMENT_MACRO(imag) |
sv | 1:6799c07fe510 | 303 | TVMET_IMPLEMENT_MACRO(arg) |
sv | 1:6799c07fe510 | 304 | TVMET_IMPLEMENT_MACRO(norm) |
sv | 1:6799c07fe510 | 305 | |
sv | 1:6799c07fe510 | 306 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 307 | |
sv | 1:6799c07fe510 | 308 | #endif // defined(TVMET_HAVE_COMPLEX) |
sv | 1:6799c07fe510 | 309 | |
sv | 1:6799c07fe510 | 310 | |
sv | 1:6799c07fe510 | 311 | #if defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 312 | |
sv | 1:6799c07fe510 | 313 | /** \class Fcnl_isnan UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 314 | /** \class Fcnl_isinf UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 315 | /** \class Fcnl_finite UnaryFunctionals.h "tvmet/UnaryFunctionals.h" */ |
sv | 1:6799c07fe510 | 316 | #define TVMET_IMPLEMENT_MACRO(NAME, POD) \ |
sv | 1:6799c07fe510 | 317 | template <class T> \ |
sv | 1:6799c07fe510 | 318 | struct Fcnl_##NAME : public UnaryFunctional { \ |
sv | 1:6799c07fe510 | 319 | typedef T value_type; \ |
sv | 1:6799c07fe510 | 320 | \ |
sv | 1:6799c07fe510 | 321 | static inline \ |
sv | 1:6799c07fe510 | 322 | POD apply_on(T rhs) { \ |
sv | 1:6799c07fe510 | 323 | return TVMET_GLOBAL_SCOPE(NAME)(rhs); \ |
sv | 1:6799c07fe510 | 324 | } \ |
sv | 1:6799c07fe510 | 325 | \ |
sv | 1:6799c07fe510 | 326 | static \ |
sv | 1:6799c07fe510 | 327 | void print_xpr(std::ostream& os, std::size_t l=0) { \ |
sv | 1:6799c07fe510 | 328 | os << IndentLevel(l) << "Fcnl_" << #NAME << "<T=" \ |
sv | 1:6799c07fe510 | 329 | << typeid(POD).name() << ">," \ |
sv | 1:6799c07fe510 | 330 | << std::endl; \ |
sv | 1:6799c07fe510 | 331 | } \ |
sv | 1:6799c07fe510 | 332 | }; |
sv | 1:6799c07fe510 | 333 | |
sv | 1:6799c07fe510 | 334 | TVMET_IMPLEMENT_MACRO(isnan, int) |
sv | 1:6799c07fe510 | 335 | TVMET_IMPLEMENT_MACRO(isinf, int) |
sv | 1:6799c07fe510 | 336 | TVMET_IMPLEMENT_MACRO(finite, int) |
sv | 1:6799c07fe510 | 337 | |
sv | 1:6799c07fe510 | 338 | #undef TVMET_IMPLEMENT_MACRO |
sv | 1:6799c07fe510 | 339 | |
sv | 1:6799c07fe510 | 340 | #endif // defined(TVMET_HAVE_IEEE_MATH) |
sv | 1:6799c07fe510 | 341 | |
sv | 1:6799c07fe510 | 342 | } // namespace tvmet |
sv | 1:6799c07fe510 | 343 | |
sv | 1:6799c07fe510 | 344 | #endif // TVMET_UNARY_FUNCTIONAL_H |
sv | 1:6799c07fe510 | 345 | |
sv | 1:6799c07fe510 | 346 | // Local Variables: |
sv | 1:6799c07fe510 | 347 | // mode:C++ |
sv | 1:6799c07fe510 | 348 | // tab-width:8 |
sv | 1:6799c07fe510 | 349 | // End: |