ICRS Eurobot 2013

Dependencies:   mbed mbed-rtos Servo QEI

Committer:
madcowswe
Date:
Sat Apr 06 20:57:54 2013 +0000
Revision:
15:9c5aaeda36dc
Encoders fairly tuned, still has random noise in it

Who changed what in which revision?

UserRevisionLine numberNew contents of line
madcowswe 15:9c5aaeda36dc 1 /*
madcowswe 15:9c5aaeda36dc 2 * Tiny Vector Matrix Library
madcowswe 15:9c5aaeda36dc 3 * Dense Vector Matrix Libary of Tiny size using Expression Templates
madcowswe 15:9c5aaeda36dc 4 *
madcowswe 15:9c5aaeda36dc 5 * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
madcowswe 15:9c5aaeda36dc 6 *
madcowswe 15:9c5aaeda36dc 7 * This library is free software; you can redistribute it and/or
madcowswe 15:9c5aaeda36dc 8 * modify it under the terms of the GNU Lesser General Public
madcowswe 15:9c5aaeda36dc 9 * License as published by the Free Software Foundation; either
madcowswe 15:9c5aaeda36dc 10 * version 2.1 of the License, or (at your option) any later version.
madcowswe 15:9c5aaeda36dc 11 *
madcowswe 15:9c5aaeda36dc 12 * This library is distributed in the hope that it will be useful,
madcowswe 15:9c5aaeda36dc 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
madcowswe 15:9c5aaeda36dc 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
madcowswe 15:9c5aaeda36dc 15 * Lesser General Public License for more details.
madcowswe 15:9c5aaeda36dc 16 *
madcowswe 15:9c5aaeda36dc 17 * You should have received a copy of the GNU Lesser General Public
madcowswe 15:9c5aaeda36dc 18 * License along with this library; if not, write to the Free Software
madcowswe 15:9c5aaeda36dc 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
madcowswe 15:9c5aaeda36dc 20 *
madcowswe 15:9c5aaeda36dc 21 * $Id: BinaryFunctionals.h,v 1.24 2007-06-23 15:58:58 opetzold Exp $
madcowswe 15:9c5aaeda36dc 22 */
madcowswe 15:9c5aaeda36dc 23
madcowswe 15:9c5aaeda36dc 24 #ifndef TVMET_BINARY_FUNCTIONAL_H
madcowswe 15:9c5aaeda36dc 25 #define TVMET_BINARY_FUNCTIONAL_H
madcowswe 15:9c5aaeda36dc 26
madcowswe 15:9c5aaeda36dc 27 namespace tvmet {
madcowswe 15:9c5aaeda36dc 28
madcowswe 15:9c5aaeda36dc 29
madcowswe 15:9c5aaeda36dc 30 /**
madcowswe 15:9c5aaeda36dc 31 * \class Fcnl_assign BinaryFunctionals.h "tvmet/BinaryFunctionals.h"
madcowswe 15:9c5aaeda36dc 32 * \brief Binary operator for assign operations.
madcowswe 15:9c5aaeda36dc 33 *
madcowswe 15:9c5aaeda36dc 34 * Unfortunally we have sometimes to cast on assign operations e.g.,
madcowswe 15:9c5aaeda36dc 35 * on assign on different POD. So we avoid warnings.
madcowswe 15:9c5aaeda36dc 36 */
madcowswe 15:9c5aaeda36dc 37 template <class T1, class T2>
madcowswe 15:9c5aaeda36dc 38 struct Fcnl_assign : public BinaryFunctional {
madcowswe 15:9c5aaeda36dc 39 static inline
madcowswe 15:9c5aaeda36dc 40 void apply_on(T1& _tvmet_restrict lhs, T2 rhs) {
madcowswe 15:9c5aaeda36dc 41 lhs = static_cast<T1>(rhs);
madcowswe 15:9c5aaeda36dc 42 }
madcowswe 15:9c5aaeda36dc 43
madcowswe 15:9c5aaeda36dc 44 static
madcowswe 15:9c5aaeda36dc 45 void print_xpr(std::ostream& os, std::size_t l=0) {
madcowswe 15:9c5aaeda36dc 46 os << IndentLevel(l) << "fcnl_assign<T1="
madcowswe 15:9c5aaeda36dc 47 << typeid(T1).name() << ", T2=" << typeid(T2).name() << ">,"
madcowswe 15:9c5aaeda36dc 48 << std::endl;
madcowswe 15:9c5aaeda36dc 49 }
madcowswe 15:9c5aaeda36dc 50 };
madcowswe 15:9c5aaeda36dc 51
madcowswe 15:9c5aaeda36dc 52
madcowswe 15:9c5aaeda36dc 53 /** \class Fcnl_add_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 54 /** \class Fcnl_sub_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 55 /** \class Fcnl_mul_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 56 /** \class Fcnl_div_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 57 /** \class Fcnl_mod_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 58 /** \class Fcnl_xor_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 59 /** \class Fcnl_and_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 60 /** \class Fcnl_or_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 61 /** \class Fcnl_shl_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 62 /** \class Fcnl_shr_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 63 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 64 template <class T1, class T2> \
madcowswe 15:9c5aaeda36dc 65 struct Fcnl_##NAME : public BinaryFunctional { \
madcowswe 15:9c5aaeda36dc 66 typedef void value_type; \
madcowswe 15:9c5aaeda36dc 67 \
madcowswe 15:9c5aaeda36dc 68 static inline \
madcowswe 15:9c5aaeda36dc 69 void apply_on(T1& _tvmet_restrict lhs, T2 rhs) { \
madcowswe 15:9c5aaeda36dc 70 lhs OP rhs; \
madcowswe 15:9c5aaeda36dc 71 } \
madcowswe 15:9c5aaeda36dc 72 \
madcowswe 15:9c5aaeda36dc 73 static \
madcowswe 15:9c5aaeda36dc 74 void print_xpr(std::ostream& os, std::size_t l=0) { \
madcowswe 15:9c5aaeda36dc 75 os << IndentLevel(l) \
madcowswe 15:9c5aaeda36dc 76 << "Fcnl_" << #NAME << "<T1=" \
madcowswe 15:9c5aaeda36dc 77 << typeid(T1).name() << ", T2=" << typeid(T2).name() << ">," \
madcowswe 15:9c5aaeda36dc 78 << std::endl; \
madcowswe 15:9c5aaeda36dc 79 } \
madcowswe 15:9c5aaeda36dc 80 };
madcowswe 15:9c5aaeda36dc 81
madcowswe 15:9c5aaeda36dc 82 TVMET_IMPLEMENT_MACRO(add_eq, +=)
madcowswe 15:9c5aaeda36dc 83 TVMET_IMPLEMENT_MACRO(sub_eq, -=)
madcowswe 15:9c5aaeda36dc 84 TVMET_IMPLEMENT_MACRO(mul_eq, *=)
madcowswe 15:9c5aaeda36dc 85 TVMET_IMPLEMENT_MACRO(div_eq, /=)
madcowswe 15:9c5aaeda36dc 86 TVMET_IMPLEMENT_MACRO(mod_eq, %=)
madcowswe 15:9c5aaeda36dc 87 TVMET_IMPLEMENT_MACRO(xor_eq, ^=)
madcowswe 15:9c5aaeda36dc 88 TVMET_IMPLEMENT_MACRO(and_eq, &=)
madcowswe 15:9c5aaeda36dc 89 TVMET_IMPLEMENT_MACRO(or_eq, |=)
madcowswe 15:9c5aaeda36dc 90 TVMET_IMPLEMENT_MACRO(shl_eq, <<=)
madcowswe 15:9c5aaeda36dc 91 TVMET_IMPLEMENT_MACRO(shr_eq, >>=)
madcowswe 15:9c5aaeda36dc 92
madcowswe 15:9c5aaeda36dc 93 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 94
madcowswe 15:9c5aaeda36dc 95
madcowswe 15:9c5aaeda36dc 96 /** \class Fcnl_add BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 97 /** \class Fcnl_sub BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 98 /** \class Fcnl_mul BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 99 /** \class Fcnl_div BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 100 /** \class Fcnl_mod BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 101 /** \class Fcnl_bitxor BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 102 /** \class Fcnl_bitand BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 103 /** \class Fcnl_bitor BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 104 /** \class Fcnl_shl BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 105 /** \class Fcnl_shr BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 106 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 107 template <class T1, class T2> \
madcowswe 15:9c5aaeda36dc 108 struct Fcnl_##NAME : public BinaryFunctional { \
madcowswe 15:9c5aaeda36dc 109 typedef typename PromoteTraits<T1, T2>::value_type value_type; \
madcowswe 15:9c5aaeda36dc 110 \
madcowswe 15:9c5aaeda36dc 111 static inline \
madcowswe 15:9c5aaeda36dc 112 value_type apply_on(T1 lhs, T2 rhs) { \
madcowswe 15:9c5aaeda36dc 113 return lhs OP rhs; \
madcowswe 15:9c5aaeda36dc 114 } \
madcowswe 15:9c5aaeda36dc 115 \
madcowswe 15:9c5aaeda36dc 116 static \
madcowswe 15:9c5aaeda36dc 117 void print_xpr(std::ostream& os, std::size_t l=0) { \
madcowswe 15:9c5aaeda36dc 118 os << IndentLevel(l) \
madcowswe 15:9c5aaeda36dc 119 << "Fcnl_" << #NAME << "<T1=" \
madcowswe 15:9c5aaeda36dc 120 << typeid(T1).name() << ", T2=" << typeid(T2).name() << ">," \
madcowswe 15:9c5aaeda36dc 121 << std::endl; \
madcowswe 15:9c5aaeda36dc 122 } \
madcowswe 15:9c5aaeda36dc 123 };
madcowswe 15:9c5aaeda36dc 124
madcowswe 15:9c5aaeda36dc 125 TVMET_IMPLEMENT_MACRO(add, +)
madcowswe 15:9c5aaeda36dc 126 TVMET_IMPLEMENT_MACRO(sub, -)
madcowswe 15:9c5aaeda36dc 127 TVMET_IMPLEMENT_MACRO(mul, *)
madcowswe 15:9c5aaeda36dc 128 TVMET_IMPLEMENT_MACRO(div, /)
madcowswe 15:9c5aaeda36dc 129 TVMET_IMPLEMENT_MACRO(mod, %)
madcowswe 15:9c5aaeda36dc 130 TVMET_IMPLEMENT_MACRO(bitxor, ^)
madcowswe 15:9c5aaeda36dc 131 TVMET_IMPLEMENT_MACRO(bitand, &)
madcowswe 15:9c5aaeda36dc 132 TVMET_IMPLEMENT_MACRO(bitor, |)
madcowswe 15:9c5aaeda36dc 133 TVMET_IMPLEMENT_MACRO(shl, <<)
madcowswe 15:9c5aaeda36dc 134 TVMET_IMPLEMENT_MACRO(shr, >>)
madcowswe 15:9c5aaeda36dc 135
madcowswe 15:9c5aaeda36dc 136 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 137
madcowswe 15:9c5aaeda36dc 138
madcowswe 15:9c5aaeda36dc 139 /** \class Fcnl_greater BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 140 /** \class Fcnl_greater_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 141 /** \class Fcnl_less BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 142 /** \class Fcnl_less_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 143 /** \class Fcnl_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 144 /** \class Fcnl_not_eq BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 145 /** \class Fcnl_and BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 146 /** \class Fcnl_or BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 147 #define TVMET_IMPLEMENT_MACRO(NAME, OP) \
madcowswe 15:9c5aaeda36dc 148 template <class T1, class T2> \
madcowswe 15:9c5aaeda36dc 149 struct Fcnl_##NAME : public BinaryFunctional { \
madcowswe 15:9c5aaeda36dc 150 typedef bool value_type; \
madcowswe 15:9c5aaeda36dc 151 \
madcowswe 15:9c5aaeda36dc 152 static inline \
madcowswe 15:9c5aaeda36dc 153 bool apply_on(T1 lhs, T2 rhs) { \
madcowswe 15:9c5aaeda36dc 154 return lhs OP rhs; \
madcowswe 15:9c5aaeda36dc 155 } \
madcowswe 15:9c5aaeda36dc 156 \
madcowswe 15:9c5aaeda36dc 157 static \
madcowswe 15:9c5aaeda36dc 158 void print_xpr(std::ostream& os, std::size_t l=0) { \
madcowswe 15:9c5aaeda36dc 159 os << IndentLevel(l) \
madcowswe 15:9c5aaeda36dc 160 << "Fcnl_" << #NAME << "<T1=" \
madcowswe 15:9c5aaeda36dc 161 << typeid(T1).name() << ", T2=" << typeid(T2).name() << ">," \
madcowswe 15:9c5aaeda36dc 162 << std::endl; \
madcowswe 15:9c5aaeda36dc 163 } \
madcowswe 15:9c5aaeda36dc 164 };
madcowswe 15:9c5aaeda36dc 165
madcowswe 15:9c5aaeda36dc 166 TVMET_IMPLEMENT_MACRO(greater, >)
madcowswe 15:9c5aaeda36dc 167 TVMET_IMPLEMENT_MACRO(less, <)
madcowswe 15:9c5aaeda36dc 168 TVMET_IMPLEMENT_MACRO(greater_eq, >=)
madcowswe 15:9c5aaeda36dc 169 TVMET_IMPLEMENT_MACRO(less_eq, <=)
madcowswe 15:9c5aaeda36dc 170 TVMET_IMPLEMENT_MACRO(eq, ==)
madcowswe 15:9c5aaeda36dc 171 TVMET_IMPLEMENT_MACRO(not_eq, !=)
madcowswe 15:9c5aaeda36dc 172 TVMET_IMPLEMENT_MACRO(and, &&)
madcowswe 15:9c5aaeda36dc 173 TVMET_IMPLEMENT_MACRO(or, ||)
madcowswe 15:9c5aaeda36dc 174
madcowswe 15:9c5aaeda36dc 175 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 176
madcowswe 15:9c5aaeda36dc 177
madcowswe 15:9c5aaeda36dc 178 /** \class Fcnl_atan2 BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 179 /** \class Fcnl_fmod BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 180 /** \class Fcnl_pow BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 181 #define TVMET_IMPLEMENT_MACRO(NAME) \
madcowswe 15:9c5aaeda36dc 182 template <class T1, class T2> \
madcowswe 15:9c5aaeda36dc 183 struct Fcnl_##NAME : public BinaryFunctional { \
madcowswe 15:9c5aaeda36dc 184 typedef typename PromoteTraits<T1, T2>::value_type value_type; \
madcowswe 15:9c5aaeda36dc 185 \
madcowswe 15:9c5aaeda36dc 186 static inline \
madcowswe 15:9c5aaeda36dc 187 value_type apply_on(T1 lhs, T2 rhs) { \
madcowswe 15:9c5aaeda36dc 188 return TVMET_STD_SCOPE(NAME)(lhs, rhs); \
madcowswe 15:9c5aaeda36dc 189 } \
madcowswe 15:9c5aaeda36dc 190 \
madcowswe 15:9c5aaeda36dc 191 static \
madcowswe 15:9c5aaeda36dc 192 void print_xpr(std::ostream& os, std::size_t l=0) { \
madcowswe 15:9c5aaeda36dc 193 os << IndentLevel(l) \
madcowswe 15:9c5aaeda36dc 194 << "Fcnl_" << #NAME << "<T1=" \
madcowswe 15:9c5aaeda36dc 195 << typeid(T1).name() << ", T2=" << typeid(T2).name() << ">," \
madcowswe 15:9c5aaeda36dc 196 << std::endl; \
madcowswe 15:9c5aaeda36dc 197 } \
madcowswe 15:9c5aaeda36dc 198 };
madcowswe 15:9c5aaeda36dc 199
madcowswe 15:9c5aaeda36dc 200 TVMET_IMPLEMENT_MACRO(atan2)
madcowswe 15:9c5aaeda36dc 201 TVMET_IMPLEMENT_MACRO(fmod)
madcowswe 15:9c5aaeda36dc 202 TVMET_IMPLEMENT_MACRO(pow)
madcowswe 15:9c5aaeda36dc 203
madcowswe 15:9c5aaeda36dc 204 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 205
madcowswe 15:9c5aaeda36dc 206
madcowswe 15:9c5aaeda36dc 207 /** \class Fcnl_drem BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 208 /** \class Fcnl_hypot BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 209 /** \class Fcnl_jn BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 210 /** \class Fcnl_yn BinaryFunctionals.h "tvmet/BinaryFunctionals.h" */
madcowswe 15:9c5aaeda36dc 211 #define TVMET_IMPLEMENT_MACRO(NAME) \
madcowswe 15:9c5aaeda36dc 212 template <class T1, class T2> \
madcowswe 15:9c5aaeda36dc 213 struct Fcnl_##NAME : public BinaryFunctional { \
madcowswe 15:9c5aaeda36dc 214 typedef typename PromoteTraits<T1, T2>::value_type value_type; \
madcowswe 15:9c5aaeda36dc 215 \
madcowswe 15:9c5aaeda36dc 216 static inline \
madcowswe 15:9c5aaeda36dc 217 value_type apply_on(T1 lhs, T2 rhs) { \
madcowswe 15:9c5aaeda36dc 218 return TVMET_GLOBAL_SCOPE(NAME)(lhs, rhs); \
madcowswe 15:9c5aaeda36dc 219 } \
madcowswe 15:9c5aaeda36dc 220 \
madcowswe 15:9c5aaeda36dc 221 static \
madcowswe 15:9c5aaeda36dc 222 void print_xpr(std::ostream& os, std::size_t l=0) { \
madcowswe 15:9c5aaeda36dc 223 os << IndentLevel(l) \
madcowswe 15:9c5aaeda36dc 224 << "Fcnl_" << #NAME << "<T1=" \
madcowswe 15:9c5aaeda36dc 225 << typeid(T1).name() << ", T2=" << typeid(T2).name() << ">," \
madcowswe 15:9c5aaeda36dc 226 << std::endl; \
madcowswe 15:9c5aaeda36dc 227 } \
madcowswe 15:9c5aaeda36dc 228 };
madcowswe 15:9c5aaeda36dc 229
madcowswe 15:9c5aaeda36dc 230 TVMET_IMPLEMENT_MACRO(drem)
madcowswe 15:9c5aaeda36dc 231 TVMET_IMPLEMENT_MACRO(hypot)
madcowswe 15:9c5aaeda36dc 232 TVMET_IMPLEMENT_MACRO(jn)
madcowswe 15:9c5aaeda36dc 233 TVMET_IMPLEMENT_MACRO(yn)
madcowswe 15:9c5aaeda36dc 234
madcowswe 15:9c5aaeda36dc 235 #undef TVMET_IMPLEMENT_MACRO
madcowswe 15:9c5aaeda36dc 236
madcowswe 15:9c5aaeda36dc 237
madcowswe 15:9c5aaeda36dc 238 #if defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 239 /**
madcowswe 15:9c5aaeda36dc 240 * \class Fcnl_polar BinaryFunctionals.h "tvmet/BinaryFunctionals.h"
madcowswe 15:9c5aaeda36dc 241 * \brief %Functional for polar.
madcowswe 15:9c5aaeda36dc 242 */
madcowswe 15:9c5aaeda36dc 243 template <class T1, class T2> struct Fcnl_polar : public BinaryFunctional { };
madcowswe 15:9c5aaeda36dc 244
madcowswe 15:9c5aaeda36dc 245
madcowswe 15:9c5aaeda36dc 246 /**
madcowswe 15:9c5aaeda36dc 247 * \class Fcnl_polar<T,T> BinaryFunctionals.h "tvmet/BinaryFunctionals.h"
madcowswe 15:9c5aaeda36dc 248 * \brief %Functional for polar.
madcowswe 15:9c5aaeda36dc 249 * \note This functional is partialy specialized due to the declaration
madcowswe 15:9c5aaeda36dc 250 * of %polar in namespace std <tt>complex<T> polar(T, T)</tt>.
madcowswe 15:9c5aaeda36dc 251 * This means especially that type promotion isn't avaible here.
madcowswe 15:9c5aaeda36dc 252 */
madcowswe 15:9c5aaeda36dc 253 template <class T>
madcowswe 15:9c5aaeda36dc 254 struct Fcnl_polar<T,T> : public BinaryFunctional {
madcowswe 15:9c5aaeda36dc 255 typedef std::complex<T> value_type;
madcowswe 15:9c5aaeda36dc 256
madcowswe 15:9c5aaeda36dc 257 static inline
madcowswe 15:9c5aaeda36dc 258 value_type apply_on(T lhs, T rhs) {
madcowswe 15:9c5aaeda36dc 259 return std::polar(lhs, rhs);
madcowswe 15:9c5aaeda36dc 260 }
madcowswe 15:9c5aaeda36dc 261
madcowswe 15:9c5aaeda36dc 262 static
madcowswe 15:9c5aaeda36dc 263 void print_xpr(std::ostream& os, std::size_t l=0) {
madcowswe 15:9c5aaeda36dc 264 os << IndentLevel(l) << "Fcnl_polar<T1="
madcowswe 15:9c5aaeda36dc 265 << typeid(T).name() << ", T2=" << typeid(T).name() << ">,"
madcowswe 15:9c5aaeda36dc 266 << std::endl;
madcowswe 15:9c5aaeda36dc 267 }
madcowswe 15:9c5aaeda36dc 268 };
madcowswe 15:9c5aaeda36dc 269 #endif // defined(TVMET_HAVE_COMPLEX)
madcowswe 15:9c5aaeda36dc 270
madcowswe 15:9c5aaeda36dc 271
madcowswe 15:9c5aaeda36dc 272 /**
madcowswe 15:9c5aaeda36dc 273 * \class Fcnl_swap BinaryFunctionals.h "tvmet/BinaryFunctionals.h"
madcowswe 15:9c5aaeda36dc 274 * \brief Binary operator for swapping values using temporaries.
madcowswe 15:9c5aaeda36dc 275 */
madcowswe 15:9c5aaeda36dc 276 template <class T1, class T2>
madcowswe 15:9c5aaeda36dc 277 struct Fcnl_swap : public BinaryFunctional {
madcowswe 15:9c5aaeda36dc 278 static inline
madcowswe 15:9c5aaeda36dc 279 void apply_on(T1& _tvmet_restrict lhs, T2& _tvmet_restrict rhs) {
madcowswe 15:9c5aaeda36dc 280 typedef typename PromoteTraits<T1, T2>::value_type temp_type;
madcowswe 15:9c5aaeda36dc 281
madcowswe 15:9c5aaeda36dc 282 temp_type temp(lhs);
madcowswe 15:9c5aaeda36dc 283 lhs = static_cast<T1>(rhs);
madcowswe 15:9c5aaeda36dc 284 rhs = static_cast<T2>(temp);
madcowswe 15:9c5aaeda36dc 285 }
madcowswe 15:9c5aaeda36dc 286
madcowswe 15:9c5aaeda36dc 287 static
madcowswe 15:9c5aaeda36dc 288 void print_xpr(std::ostream& os, std::size_t l=0) {
madcowswe 15:9c5aaeda36dc 289 os << IndentLevel(l) << "Fcnl_swap<T1="
madcowswe 15:9c5aaeda36dc 290 << typeid(T1).name() << ", T2" << typeid(T2).name() << ">,"
madcowswe 15:9c5aaeda36dc 291 << std::endl;
madcowswe 15:9c5aaeda36dc 292 }
madcowswe 15:9c5aaeda36dc 293 };
madcowswe 15:9c5aaeda36dc 294
madcowswe 15:9c5aaeda36dc 295
madcowswe 15:9c5aaeda36dc 296 } // namespace tvmet
madcowswe 15:9c5aaeda36dc 297
madcowswe 15:9c5aaeda36dc 298 #endif // TVMET_BINARY_FUNCTIONAL_H
madcowswe 15:9c5aaeda36dc 299
madcowswe 15:9c5aaeda36dc 300 // Local Variables:
madcowswe 15:9c5aaeda36dc 301 // mode:C++
madcowswe 15:9c5aaeda36dc 302 // tab-width:8
madcowswe 15:9c5aaeda36dc 303 // End: