Eurobot2012_Secondary

Fork of Eurobot_2012_Secondary by Shuto Naruse

Committer:
narshu
Date:
Wed Oct 17 22:25:31 2012 +0000
Revision:
1:cc2a9eb0bd55
Commit before publishing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
narshu 1:cc2a9eb0bd55 1 /*
narshu 1:cc2a9eb0bd55 2 * Tiny Vector Matrix Library
narshu 1:cc2a9eb0bd55 3 * Dense Vector Matrix Libary of Tiny size using Expression Templates
narshu 1:cc2a9eb0bd55 4 *
narshu 1:cc2a9eb0bd55 5 * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
narshu 1:cc2a9eb0bd55 6 *
narshu 1:cc2a9eb0bd55 7 * This library is free software; you can redistribute it and/or
narshu 1:cc2a9eb0bd55 8 * modify it under the terms of the GNU Lesser General Public
narshu 1:cc2a9eb0bd55 9 * License as published by the Free Software Foundation; either
narshu 1:cc2a9eb0bd55 10 * version 2.1 of the License, or (at your option) any later version.
narshu 1:cc2a9eb0bd55 11 *
narshu 1:cc2a9eb0bd55 12 * This library is distributed in the hope that it will be useful,
narshu 1:cc2a9eb0bd55 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
narshu 1:cc2a9eb0bd55 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
narshu 1:cc2a9eb0bd55 15 * Lesser General Public License for more details.
narshu 1:cc2a9eb0bd55 16 *
narshu 1:cc2a9eb0bd55 17 * You should have received a copy of the GNU Lesser General Public
narshu 1:cc2a9eb0bd55 18 * License along with this library; if not, write to the Free Software
narshu 1:cc2a9eb0bd55 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
narshu 1:cc2a9eb0bd55 20 *
narshu 1:cc2a9eb0bd55 21 * $Id: VectorBinaryFunctions.h,v 1.17 2007-06-23 15:58:58 opetzold Exp $
narshu 1:cc2a9eb0bd55 22 */
narshu 1:cc2a9eb0bd55 23
narshu 1:cc2a9eb0bd55 24 #ifndef TVMET_VECTOR_BINARY_FUNCTIONS_H
narshu 1:cc2a9eb0bd55 25 #define TVMET_VECTOR_BINARY_FUNCTIONS_H
narshu 1:cc2a9eb0bd55 26
narshu 1:cc2a9eb0bd55 27 #include <tvmet/NumericTraits.h>
narshu 1:cc2a9eb0bd55 28 #include <tvmet/Extremum.h>
narshu 1:cc2a9eb0bd55 29
narshu 1:cc2a9eb0bd55 30 namespace tvmet {
narshu 1:cc2a9eb0bd55 31
narshu 1:cc2a9eb0bd55 32
narshu 1:cc2a9eb0bd55 33 /*********************************************************
narshu 1:cc2a9eb0bd55 34 * PART I: DECLARATION
narshu 1:cc2a9eb0bd55 35 *********************************************************/
narshu 1:cc2a9eb0bd55 36
narshu 1:cc2a9eb0bd55 37 /*
narshu 1:cc2a9eb0bd55 38 * binary_function(Vector<T1, Sz>, Vector<T1, Sz>)
narshu 1:cc2a9eb0bd55 39 * binary_function(Vector<T, Sz>, XprVector<E>)
narshu 1:cc2a9eb0bd55 40 * binary_function(XprVector<E>, Vector<T, Sz>)
narshu 1:cc2a9eb0bd55 41 */
narshu 1:cc2a9eb0bd55 42 #define TVMET_DECLARE_MACRO(NAME) \
narshu 1:cc2a9eb0bd55 43 template<class T1, class T2, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 44 inline \
narshu 1:cc2a9eb0bd55 45 XprVector< \
narshu 1:cc2a9eb0bd55 46 XprBinOp< \
narshu 1:cc2a9eb0bd55 47 Fcnl_##NAME<T1, T2>, \
narshu 1:cc2a9eb0bd55 48 VectorConstReference<T1, Sz>, \
narshu 1:cc2a9eb0bd55 49 VectorConstReference<T2, Sz> \
narshu 1:cc2a9eb0bd55 50 >, \
narshu 1:cc2a9eb0bd55 51 Sz \
narshu 1:cc2a9eb0bd55 52 > \
narshu 1:cc2a9eb0bd55 53 NAME(const Vector<T1, Sz>& lhs, \
narshu 1:cc2a9eb0bd55 54 const Vector<T2, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE; \
narshu 1:cc2a9eb0bd55 55 \
narshu 1:cc2a9eb0bd55 56 template<class E, class T, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 57 inline \
narshu 1:cc2a9eb0bd55 58 XprVector< \
narshu 1:cc2a9eb0bd55 59 XprBinOp< \
narshu 1:cc2a9eb0bd55 60 Fcnl_##NAME<typename E::value_type, T>, \
narshu 1:cc2a9eb0bd55 61 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 62 XprVector<E, Sz> \
narshu 1:cc2a9eb0bd55 63 >, \
narshu 1:cc2a9eb0bd55 64 Sz \
narshu 1:cc2a9eb0bd55 65 > \
narshu 1:cc2a9eb0bd55 66 NAME(const XprVector<E, Sz>& lhs, \
narshu 1:cc2a9eb0bd55 67 const Vector<T, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE; \
narshu 1:cc2a9eb0bd55 68 \
narshu 1:cc2a9eb0bd55 69 template<class E, class T, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 70 inline \
narshu 1:cc2a9eb0bd55 71 XprVector< \
narshu 1:cc2a9eb0bd55 72 XprBinOp< \
narshu 1:cc2a9eb0bd55 73 Fcnl_##NAME<T, typename E::value_type>, \
narshu 1:cc2a9eb0bd55 74 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 75 XprVector<E, Sz> \
narshu 1:cc2a9eb0bd55 76 >, \
narshu 1:cc2a9eb0bd55 77 Sz \
narshu 1:cc2a9eb0bd55 78 > \
narshu 1:cc2a9eb0bd55 79 NAME(const Vector<T, Sz>& lhs, \
narshu 1:cc2a9eb0bd55 80 const XprVector<E, Sz>& rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 1:cc2a9eb0bd55 81
narshu 1:cc2a9eb0bd55 82 TVMET_DECLARE_MACRO(atan2)
narshu 1:cc2a9eb0bd55 83 TVMET_DECLARE_MACRO(drem)
narshu 1:cc2a9eb0bd55 84 TVMET_DECLARE_MACRO(fmod)
narshu 1:cc2a9eb0bd55 85 TVMET_DECLARE_MACRO(hypot)
narshu 1:cc2a9eb0bd55 86 TVMET_DECLARE_MACRO(jn)
narshu 1:cc2a9eb0bd55 87 TVMET_DECLARE_MACRO(yn)
narshu 1:cc2a9eb0bd55 88 TVMET_DECLARE_MACRO(pow)
narshu 1:cc2a9eb0bd55 89 #if defined(TVMET_HAVE_COMPLEX)
narshu 1:cc2a9eb0bd55 90 TVMET_DECLARE_MACRO(polar)
narshu 1:cc2a9eb0bd55 91 #endif
narshu 1:cc2a9eb0bd55 92
narshu 1:cc2a9eb0bd55 93 #undef TVMET_DECLARE_MACRO
narshu 1:cc2a9eb0bd55 94
narshu 1:cc2a9eb0bd55 95
narshu 1:cc2a9eb0bd55 96 /*
narshu 1:cc2a9eb0bd55 97 * binary_function(Vector<T, Sz>, POD)
narshu 1:cc2a9eb0bd55 98 */
narshu 1:cc2a9eb0bd55 99 #define TVMET_DECLARE_MACRO(NAME, TP) \
narshu 1:cc2a9eb0bd55 100 template<class T, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 101 inline \
narshu 1:cc2a9eb0bd55 102 XprVector< \
narshu 1:cc2a9eb0bd55 103 XprBinOp< \
narshu 1:cc2a9eb0bd55 104 Fcnl_##NAME<T, TP >, \
narshu 1:cc2a9eb0bd55 105 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 106 XprLiteral< TP > \
narshu 1:cc2a9eb0bd55 107 >, \
narshu 1:cc2a9eb0bd55 108 Sz \
narshu 1:cc2a9eb0bd55 109 > \
narshu 1:cc2a9eb0bd55 110 NAME(const Vector<T, Sz>& lhs, TP rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 1:cc2a9eb0bd55 111
narshu 1:cc2a9eb0bd55 112 TVMET_DECLARE_MACRO(atan2, int)
narshu 1:cc2a9eb0bd55 113 TVMET_DECLARE_MACRO(drem, int)
narshu 1:cc2a9eb0bd55 114 TVMET_DECLARE_MACRO(fmod, int)
narshu 1:cc2a9eb0bd55 115 TVMET_DECLARE_MACRO(hypot, int)
narshu 1:cc2a9eb0bd55 116 TVMET_DECLARE_MACRO(jn, int)
narshu 1:cc2a9eb0bd55 117 TVMET_DECLARE_MACRO(yn, int)
narshu 1:cc2a9eb0bd55 118 TVMET_DECLARE_MACRO(pow, int)
narshu 1:cc2a9eb0bd55 119
narshu 1:cc2a9eb0bd55 120 #if defined(TVMET_HAVE_LONG_LONG)
narshu 1:cc2a9eb0bd55 121 TVMET_DECLARE_MACRO(atan2, long long int)
narshu 1:cc2a9eb0bd55 122 TVMET_DECLARE_MACRO(drem, long long int)
narshu 1:cc2a9eb0bd55 123 TVMET_DECLARE_MACRO(fmod, long long int)
narshu 1:cc2a9eb0bd55 124 TVMET_DECLARE_MACRO(hypot, long long int)
narshu 1:cc2a9eb0bd55 125 TVMET_DECLARE_MACRO(jn, long long int)
narshu 1:cc2a9eb0bd55 126 TVMET_DECLARE_MACRO(yn, long long int)
narshu 1:cc2a9eb0bd55 127 TVMET_DECLARE_MACRO(pow, long long int)
narshu 1:cc2a9eb0bd55 128 #endif // defined(TVMET_HAVE_LONG_LONG)
narshu 1:cc2a9eb0bd55 129
narshu 1:cc2a9eb0bd55 130 TVMET_DECLARE_MACRO(atan2, float)
narshu 1:cc2a9eb0bd55 131 TVMET_DECLARE_MACRO(drem, float)
narshu 1:cc2a9eb0bd55 132 TVMET_DECLARE_MACRO(fmod, float)
narshu 1:cc2a9eb0bd55 133 TVMET_DECLARE_MACRO(hypot, float)
narshu 1:cc2a9eb0bd55 134 TVMET_DECLARE_MACRO(jn, float)
narshu 1:cc2a9eb0bd55 135 TVMET_DECLARE_MACRO(yn, float)
narshu 1:cc2a9eb0bd55 136 TVMET_DECLARE_MACRO(pow, float)
narshu 1:cc2a9eb0bd55 137
narshu 1:cc2a9eb0bd55 138 TVMET_DECLARE_MACRO(atan2, double)
narshu 1:cc2a9eb0bd55 139 TVMET_DECLARE_MACRO(drem, double)
narshu 1:cc2a9eb0bd55 140 TVMET_DECLARE_MACRO(fmod, double)
narshu 1:cc2a9eb0bd55 141 TVMET_DECLARE_MACRO(hypot, double)
narshu 1:cc2a9eb0bd55 142 TVMET_DECLARE_MACRO(jn, double)
narshu 1:cc2a9eb0bd55 143 TVMET_DECLARE_MACRO(yn, double)
narshu 1:cc2a9eb0bd55 144 TVMET_DECLARE_MACRO(pow, double)
narshu 1:cc2a9eb0bd55 145
narshu 1:cc2a9eb0bd55 146 #if defined(TVMET_HAVE_LONG_DOUBLE)
narshu 1:cc2a9eb0bd55 147 TVMET_DECLARE_MACRO(atan2, long double)
narshu 1:cc2a9eb0bd55 148 TVMET_DECLARE_MACRO(drem, long double)
narshu 1:cc2a9eb0bd55 149 TVMET_DECLARE_MACRO(fmod, long double)
narshu 1:cc2a9eb0bd55 150 TVMET_DECLARE_MACRO(hypot, long double)
narshu 1:cc2a9eb0bd55 151 TVMET_DECLARE_MACRO(jn, long double)
narshu 1:cc2a9eb0bd55 152 TVMET_DECLARE_MACRO(yn, long double)
narshu 1:cc2a9eb0bd55 153 TVMET_DECLARE_MACRO(pow, long double)
narshu 1:cc2a9eb0bd55 154 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
narshu 1:cc2a9eb0bd55 155
narshu 1:cc2a9eb0bd55 156 #undef TVMET_DECLARE_MACRO
narshu 1:cc2a9eb0bd55 157
narshu 1:cc2a9eb0bd55 158
narshu 1:cc2a9eb0bd55 159 /*
narshu 1:cc2a9eb0bd55 160 * complex support
narshu 1:cc2a9eb0bd55 161 */
narshu 1:cc2a9eb0bd55 162
narshu 1:cc2a9eb0bd55 163 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
narshu 1:cc2a9eb0bd55 164 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 165 XprVector<
narshu 1:cc2a9eb0bd55 166 XprBinOp<
narshu 1:cc2a9eb0bd55 167 Fcnl_pow<T, std::complex<T> >,
narshu 1:cc2a9eb0bd55 168 VectorConstReference<T, Sz>,
narshu 1:cc2a9eb0bd55 169 XprLiteral< std::complex<T> >
narshu 1:cc2a9eb0bd55 170 >,
narshu 1:cc2a9eb0bd55 171 Sz
narshu 1:cc2a9eb0bd55 172 >
narshu 1:cc2a9eb0bd55 173 pow(const Vector<T, Sz>& lhs,
narshu 1:cc2a9eb0bd55 174 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 1:cc2a9eb0bd55 175
narshu 1:cc2a9eb0bd55 176
narshu 1:cc2a9eb0bd55 177 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 178 XprVector<
narshu 1:cc2a9eb0bd55 179 XprBinOp<
narshu 1:cc2a9eb0bd55 180 Fcnl_pow<std::complex<T>, std::complex<T> >,
narshu 1:cc2a9eb0bd55 181 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 182 XprLiteral< std::complex<T> >
narshu 1:cc2a9eb0bd55 183 >,
narshu 1:cc2a9eb0bd55 184 Sz
narshu 1:cc2a9eb0bd55 185 >
narshu 1:cc2a9eb0bd55 186 pow(const Vector<std::complex<T>, Sz>& lhs,
narshu 1:cc2a9eb0bd55 187 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 1:cc2a9eb0bd55 188
narshu 1:cc2a9eb0bd55 189
narshu 1:cc2a9eb0bd55 190 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 191 XprVector<
narshu 1:cc2a9eb0bd55 192 XprBinOp<
narshu 1:cc2a9eb0bd55 193 Fcnl_pow<std::complex<T>, T>,
narshu 1:cc2a9eb0bd55 194 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 195 XprLiteral<T>
narshu 1:cc2a9eb0bd55 196 >,
narshu 1:cc2a9eb0bd55 197 Sz
narshu 1:cc2a9eb0bd55 198 >
narshu 1:cc2a9eb0bd55 199 pow(const Vector<std::complex<T>, Sz>& lhs,
narshu 1:cc2a9eb0bd55 200 const T& rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 1:cc2a9eb0bd55 201
narshu 1:cc2a9eb0bd55 202
narshu 1:cc2a9eb0bd55 203 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 204 XprVector<
narshu 1:cc2a9eb0bd55 205 XprBinOp<
narshu 1:cc2a9eb0bd55 206 Fcnl_pow<std::complex<T>, int>,
narshu 1:cc2a9eb0bd55 207 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 208 XprLiteral<int>
narshu 1:cc2a9eb0bd55 209 >,
narshu 1:cc2a9eb0bd55 210 Sz
narshu 1:cc2a9eb0bd55 211 >
narshu 1:cc2a9eb0bd55 212 pow(const Vector<std::complex<T>, Sz>& lhs,
narshu 1:cc2a9eb0bd55 213 int rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 1:cc2a9eb0bd55 214
narshu 1:cc2a9eb0bd55 215
narshu 1:cc2a9eb0bd55 216 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 217 XprVector<
narshu 1:cc2a9eb0bd55 218 XprBinOp<
narshu 1:cc2a9eb0bd55 219 Fcnl_polar<T, T>,
narshu 1:cc2a9eb0bd55 220 VectorConstReference<T, Sz>,
narshu 1:cc2a9eb0bd55 221 XprLiteral<T>
narshu 1:cc2a9eb0bd55 222 >,
narshu 1:cc2a9eb0bd55 223 Sz
narshu 1:cc2a9eb0bd55 224 >
narshu 1:cc2a9eb0bd55 225 polar(const Vector<T, Sz>& lhs, const T& rhs) TVMET_CXX_ALWAYS_INLINE;
narshu 1:cc2a9eb0bd55 226
narshu 1:cc2a9eb0bd55 227 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
narshu 1:cc2a9eb0bd55 228
narshu 1:cc2a9eb0bd55 229 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
narshu 1:cc2a9eb0bd55 230 // to be written (atan2)
narshu 1:cc2a9eb0bd55 231 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
narshu 1:cc2a9eb0bd55 232
narshu 1:cc2a9eb0bd55 233
narshu 1:cc2a9eb0bd55 234 /*********************************************************
narshu 1:cc2a9eb0bd55 235 * PART II: IMPLEMENTATION
narshu 1:cc2a9eb0bd55 236 *********************************************************/
narshu 1:cc2a9eb0bd55 237
narshu 1:cc2a9eb0bd55 238 /*
narshu 1:cc2a9eb0bd55 239 * binary_function(Vector<T1, Sz>, Vector<T1, Sz>)
narshu 1:cc2a9eb0bd55 240 * binary_function(Vector<T, Sz>, XprVector<E>)
narshu 1:cc2a9eb0bd55 241 * binary_function(XprVector<E>, Vector<T, Sz>)
narshu 1:cc2a9eb0bd55 242 */
narshu 1:cc2a9eb0bd55 243 #define TVMET_IMPLEMENT_MACRO(NAME) \
narshu 1:cc2a9eb0bd55 244 template<class T1, class T2, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 245 inline \
narshu 1:cc2a9eb0bd55 246 XprVector< \
narshu 1:cc2a9eb0bd55 247 XprBinOp< \
narshu 1:cc2a9eb0bd55 248 Fcnl_##NAME<T1, T2>, \
narshu 1:cc2a9eb0bd55 249 VectorConstReference<T1, Sz>, \
narshu 1:cc2a9eb0bd55 250 VectorConstReference<T2, Sz> \
narshu 1:cc2a9eb0bd55 251 >, \
narshu 1:cc2a9eb0bd55 252 Sz \
narshu 1:cc2a9eb0bd55 253 > \
narshu 1:cc2a9eb0bd55 254 NAME(const Vector<T1, Sz>& lhs, const Vector<T2, Sz>& rhs) { \
narshu 1:cc2a9eb0bd55 255 typedef XprBinOp < \
narshu 1:cc2a9eb0bd55 256 Fcnl_##NAME<T1, T2>, \
narshu 1:cc2a9eb0bd55 257 VectorConstReference<T1, Sz>, \
narshu 1:cc2a9eb0bd55 258 VectorConstReference<T2, Sz> \
narshu 1:cc2a9eb0bd55 259 > expr_type; \
narshu 1:cc2a9eb0bd55 260 return XprVector<expr_type, Sz>( \
narshu 1:cc2a9eb0bd55 261 expr_type(lhs.const_ref(), rhs.const_ref())); \
narshu 1:cc2a9eb0bd55 262 } \
narshu 1:cc2a9eb0bd55 263 \
narshu 1:cc2a9eb0bd55 264 template<class E, class T, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 265 inline \
narshu 1:cc2a9eb0bd55 266 XprVector< \
narshu 1:cc2a9eb0bd55 267 XprBinOp< \
narshu 1:cc2a9eb0bd55 268 Fcnl_##NAME<typename E::value_type, T>, \
narshu 1:cc2a9eb0bd55 269 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 270 XprVector<E, Sz> \
narshu 1:cc2a9eb0bd55 271 >, \
narshu 1:cc2a9eb0bd55 272 Sz \
narshu 1:cc2a9eb0bd55 273 > \
narshu 1:cc2a9eb0bd55 274 NAME(const XprVector<E, Sz>& lhs, const Vector<T, Sz>& rhs) { \
narshu 1:cc2a9eb0bd55 275 typedef XprBinOp< \
narshu 1:cc2a9eb0bd55 276 Fcnl_##NAME<typename E::value_type, T>, \
narshu 1:cc2a9eb0bd55 277 XprVector<E, Sz>, \
narshu 1:cc2a9eb0bd55 278 VectorConstReference<T, Sz> \
narshu 1:cc2a9eb0bd55 279 > expr_type; \
narshu 1:cc2a9eb0bd55 280 return XprVector<expr_type, Sz>( \
narshu 1:cc2a9eb0bd55 281 expr_type(lhs, rhs.const_ref())); \
narshu 1:cc2a9eb0bd55 282 } \
narshu 1:cc2a9eb0bd55 283 \
narshu 1:cc2a9eb0bd55 284 template<class E, class T, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 285 inline \
narshu 1:cc2a9eb0bd55 286 XprVector< \
narshu 1:cc2a9eb0bd55 287 XprBinOp< \
narshu 1:cc2a9eb0bd55 288 Fcnl_##NAME<T, typename E::value_type>, \
narshu 1:cc2a9eb0bd55 289 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 290 XprVector<E, Sz> \
narshu 1:cc2a9eb0bd55 291 >, \
narshu 1:cc2a9eb0bd55 292 Sz \
narshu 1:cc2a9eb0bd55 293 > \
narshu 1:cc2a9eb0bd55 294 NAME(const Vector<T, Sz>& lhs, const XprVector<E, Sz>& rhs) { \
narshu 1:cc2a9eb0bd55 295 typedef XprBinOp< \
narshu 1:cc2a9eb0bd55 296 Fcnl_##NAME<T, typename E::value_type>, \
narshu 1:cc2a9eb0bd55 297 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 298 XprVector<E, Sz> \
narshu 1:cc2a9eb0bd55 299 > expr_type; \
narshu 1:cc2a9eb0bd55 300 return XprVector<expr_type, Sz>( \
narshu 1:cc2a9eb0bd55 301 expr_type(lhs.const_ref(), rhs)); \
narshu 1:cc2a9eb0bd55 302 }
narshu 1:cc2a9eb0bd55 303
narshu 1:cc2a9eb0bd55 304 TVMET_IMPLEMENT_MACRO(atan2)
narshu 1:cc2a9eb0bd55 305 TVMET_IMPLEMENT_MACRO(drem)
narshu 1:cc2a9eb0bd55 306 TVMET_IMPLEMENT_MACRO(fmod)
narshu 1:cc2a9eb0bd55 307 TVMET_IMPLEMENT_MACRO(hypot)
narshu 1:cc2a9eb0bd55 308 TVMET_IMPLEMENT_MACRO(jn)
narshu 1:cc2a9eb0bd55 309 TVMET_IMPLEMENT_MACRO(yn)
narshu 1:cc2a9eb0bd55 310 TVMET_IMPLEMENT_MACRO(pow)
narshu 1:cc2a9eb0bd55 311 #if defined(TVMET_HAVE_COMPLEX)
narshu 1:cc2a9eb0bd55 312 TVMET_IMPLEMENT_MACRO(polar)
narshu 1:cc2a9eb0bd55 313 #endif
narshu 1:cc2a9eb0bd55 314
narshu 1:cc2a9eb0bd55 315 #undef TVMET_IMPLEMENT_MACRO
narshu 1:cc2a9eb0bd55 316
narshu 1:cc2a9eb0bd55 317
narshu 1:cc2a9eb0bd55 318 /*
narshu 1:cc2a9eb0bd55 319 * binary_function(Vector<T, Sz>, POD)
narshu 1:cc2a9eb0bd55 320 */
narshu 1:cc2a9eb0bd55 321 #define TVMET_IMPLEMENT_MACRO(NAME, TP) \
narshu 1:cc2a9eb0bd55 322 template<class T, std::size_t Sz> \
narshu 1:cc2a9eb0bd55 323 inline \
narshu 1:cc2a9eb0bd55 324 XprVector< \
narshu 1:cc2a9eb0bd55 325 XprBinOp< \
narshu 1:cc2a9eb0bd55 326 Fcnl_##NAME<T, TP >, \
narshu 1:cc2a9eb0bd55 327 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 328 XprLiteral< TP > \
narshu 1:cc2a9eb0bd55 329 >, \
narshu 1:cc2a9eb0bd55 330 Sz \
narshu 1:cc2a9eb0bd55 331 > \
narshu 1:cc2a9eb0bd55 332 NAME(const Vector<T, Sz>& lhs, TP rhs) { \
narshu 1:cc2a9eb0bd55 333 typedef XprBinOp< \
narshu 1:cc2a9eb0bd55 334 Fcnl_##NAME<T, TP >, \
narshu 1:cc2a9eb0bd55 335 VectorConstReference<T, Sz>, \
narshu 1:cc2a9eb0bd55 336 XprLiteral< TP > \
narshu 1:cc2a9eb0bd55 337 > expr_type; \
narshu 1:cc2a9eb0bd55 338 return XprVector<expr_type, Sz>( \
narshu 1:cc2a9eb0bd55 339 expr_type(lhs.const_ref(), XprLiteral< TP >(rhs))); \
narshu 1:cc2a9eb0bd55 340 }
narshu 1:cc2a9eb0bd55 341
narshu 1:cc2a9eb0bd55 342 TVMET_IMPLEMENT_MACRO(atan2, int)
narshu 1:cc2a9eb0bd55 343 TVMET_IMPLEMENT_MACRO(drem, int)
narshu 1:cc2a9eb0bd55 344 TVMET_IMPLEMENT_MACRO(fmod, int)
narshu 1:cc2a9eb0bd55 345 TVMET_IMPLEMENT_MACRO(hypot, int)
narshu 1:cc2a9eb0bd55 346 TVMET_IMPLEMENT_MACRO(jn, int)
narshu 1:cc2a9eb0bd55 347 TVMET_IMPLEMENT_MACRO(yn, int)
narshu 1:cc2a9eb0bd55 348 TVMET_IMPLEMENT_MACRO(pow, int)
narshu 1:cc2a9eb0bd55 349
narshu 1:cc2a9eb0bd55 350 #if defined(TVMET_HAVE_LONG_LONG)
narshu 1:cc2a9eb0bd55 351 TVMET_IMPLEMENT_MACRO(atan2, long long int)
narshu 1:cc2a9eb0bd55 352 TVMET_IMPLEMENT_MACRO(drem, long long int)
narshu 1:cc2a9eb0bd55 353 TVMET_IMPLEMENT_MACRO(fmod, long long int)
narshu 1:cc2a9eb0bd55 354 TVMET_IMPLEMENT_MACRO(hypot, long long int)
narshu 1:cc2a9eb0bd55 355 TVMET_IMPLEMENT_MACRO(jn, long long int)
narshu 1:cc2a9eb0bd55 356 TVMET_IMPLEMENT_MACRO(yn, long long int)
narshu 1:cc2a9eb0bd55 357 TVMET_IMPLEMENT_MACRO(pow, long long int)
narshu 1:cc2a9eb0bd55 358 #endif // defined(TVMET_HAVE_LONG_LONG)
narshu 1:cc2a9eb0bd55 359
narshu 1:cc2a9eb0bd55 360 TVMET_IMPLEMENT_MACRO(atan2, float)
narshu 1:cc2a9eb0bd55 361 TVMET_IMPLEMENT_MACRO(drem, float)
narshu 1:cc2a9eb0bd55 362 TVMET_IMPLEMENT_MACRO(fmod, float)
narshu 1:cc2a9eb0bd55 363 TVMET_IMPLEMENT_MACRO(hypot, float)
narshu 1:cc2a9eb0bd55 364 TVMET_IMPLEMENT_MACRO(jn, float)
narshu 1:cc2a9eb0bd55 365 TVMET_IMPLEMENT_MACRO(yn, float)
narshu 1:cc2a9eb0bd55 366 TVMET_IMPLEMENT_MACRO(pow, float)
narshu 1:cc2a9eb0bd55 367
narshu 1:cc2a9eb0bd55 368 TVMET_IMPLEMENT_MACRO(atan2, double)
narshu 1:cc2a9eb0bd55 369 TVMET_IMPLEMENT_MACRO(drem, double)
narshu 1:cc2a9eb0bd55 370 TVMET_IMPLEMENT_MACRO(fmod, double)
narshu 1:cc2a9eb0bd55 371 TVMET_IMPLEMENT_MACRO(hypot, double)
narshu 1:cc2a9eb0bd55 372 TVMET_IMPLEMENT_MACRO(jn, double)
narshu 1:cc2a9eb0bd55 373 TVMET_IMPLEMENT_MACRO(yn, double)
narshu 1:cc2a9eb0bd55 374 TVMET_IMPLEMENT_MACRO(pow, double)
narshu 1:cc2a9eb0bd55 375
narshu 1:cc2a9eb0bd55 376 #if defined(TVMET_HAVE_LONG_DOUBLE)
narshu 1:cc2a9eb0bd55 377 TVMET_IMPLEMENT_MACRO(atan2, long double)
narshu 1:cc2a9eb0bd55 378 TVMET_IMPLEMENT_MACRO(drem, long double)
narshu 1:cc2a9eb0bd55 379 TVMET_IMPLEMENT_MACRO(fmod, long double)
narshu 1:cc2a9eb0bd55 380 TVMET_IMPLEMENT_MACRO(hypot, long double)
narshu 1:cc2a9eb0bd55 381 TVMET_IMPLEMENT_MACRO(jn, long double)
narshu 1:cc2a9eb0bd55 382 TVMET_IMPLEMENT_MACRO(yn, long double)
narshu 1:cc2a9eb0bd55 383 TVMET_IMPLEMENT_MACRO(pow, long double)
narshu 1:cc2a9eb0bd55 384 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
narshu 1:cc2a9eb0bd55 385
narshu 1:cc2a9eb0bd55 386 #undef TVMET_IMPLEMENT_MACRO
narshu 1:cc2a9eb0bd55 387
narshu 1:cc2a9eb0bd55 388
narshu 1:cc2a9eb0bd55 389 /*
narshu 1:cc2a9eb0bd55 390 * complex support
narshu 1:cc2a9eb0bd55 391 */
narshu 1:cc2a9eb0bd55 392
narshu 1:cc2a9eb0bd55 393 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
narshu 1:cc2a9eb0bd55 394 /**
narshu 1:cc2a9eb0bd55 395 * \fn pow(const Vector<T, Sz>& lhs, const std::complex<T>& rhs)
narshu 1:cc2a9eb0bd55 396 * \ingroup _binary_function
narshu 1:cc2a9eb0bd55 397 */
narshu 1:cc2a9eb0bd55 398 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 399 inline
narshu 1:cc2a9eb0bd55 400 XprVector<
narshu 1:cc2a9eb0bd55 401 XprBinOp<
narshu 1:cc2a9eb0bd55 402 Fcnl_pow<T, std::complex<T> >,
narshu 1:cc2a9eb0bd55 403 VectorConstReference<T, Sz>,
narshu 1:cc2a9eb0bd55 404 XprLiteral< std::complex<T> >
narshu 1:cc2a9eb0bd55 405 >,
narshu 1:cc2a9eb0bd55 406 Sz
narshu 1:cc2a9eb0bd55 407 >
narshu 1:cc2a9eb0bd55 408 pow(const Vector<T, Sz>& lhs, const std::complex<T>& rhs) {
narshu 1:cc2a9eb0bd55 409 typedef XprBinOp<
narshu 1:cc2a9eb0bd55 410 Fcnl_pow<T, std::complex<T> >,
narshu 1:cc2a9eb0bd55 411 VectorConstReference<T, Sz>,
narshu 1:cc2a9eb0bd55 412 XprLiteral< std::complex<T> >
narshu 1:cc2a9eb0bd55 413 > expr_type;
narshu 1:cc2a9eb0bd55 414 return XprVector<expr_type, Sz>(
narshu 1:cc2a9eb0bd55 415 expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs)));
narshu 1:cc2a9eb0bd55 416 }
narshu 1:cc2a9eb0bd55 417
narshu 1:cc2a9eb0bd55 418
narshu 1:cc2a9eb0bd55 419 /**
narshu 1:cc2a9eb0bd55 420 * \fn pow(const Vector<std::complex<T>, Sz>& lhs, const std::complex<T>& rhs)
narshu 1:cc2a9eb0bd55 421 * \ingroup _binary_function
narshu 1:cc2a9eb0bd55 422 */
narshu 1:cc2a9eb0bd55 423 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 424 inline
narshu 1:cc2a9eb0bd55 425 XprVector<
narshu 1:cc2a9eb0bd55 426 XprBinOp<
narshu 1:cc2a9eb0bd55 427 Fcnl_pow<std::complex<T>, std::complex<T> >,
narshu 1:cc2a9eb0bd55 428 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 429 XprLiteral< std::complex<T> >
narshu 1:cc2a9eb0bd55 430 >,
narshu 1:cc2a9eb0bd55 431 Sz
narshu 1:cc2a9eb0bd55 432 >
narshu 1:cc2a9eb0bd55 433 pow(const Vector<std::complex<T>, Sz>& lhs, const std::complex<T>& rhs) {
narshu 1:cc2a9eb0bd55 434 typedef XprBinOp<
narshu 1:cc2a9eb0bd55 435 Fcnl_pow<std::complex<T>, std::complex<T> >,
narshu 1:cc2a9eb0bd55 436 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 437 XprLiteral< std::complex<T> >
narshu 1:cc2a9eb0bd55 438 > expr_type;
narshu 1:cc2a9eb0bd55 439 return XprVector<expr_type, Sz>(
narshu 1:cc2a9eb0bd55 440 expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs)));
narshu 1:cc2a9eb0bd55 441 }
narshu 1:cc2a9eb0bd55 442
narshu 1:cc2a9eb0bd55 443
narshu 1:cc2a9eb0bd55 444 /**
narshu 1:cc2a9eb0bd55 445 * \fn pow(const Vector<std::complex<T>, Sz>& lhs, const T& rhs)
narshu 1:cc2a9eb0bd55 446 * \ingroup _binary_function
narshu 1:cc2a9eb0bd55 447 */
narshu 1:cc2a9eb0bd55 448 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 449 inline
narshu 1:cc2a9eb0bd55 450 XprVector<
narshu 1:cc2a9eb0bd55 451 XprBinOp<
narshu 1:cc2a9eb0bd55 452 Fcnl_pow<std::complex<T>, T>,
narshu 1:cc2a9eb0bd55 453 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 454 XprLiteral<T>
narshu 1:cc2a9eb0bd55 455 >,
narshu 1:cc2a9eb0bd55 456 Sz
narshu 1:cc2a9eb0bd55 457 >
narshu 1:cc2a9eb0bd55 458 pow(const Vector<std::complex<T>, Sz>& lhs, const T& rhs) {
narshu 1:cc2a9eb0bd55 459 typedef XprBinOp<
narshu 1:cc2a9eb0bd55 460 Fcnl_pow<std::complex<T>, T>,
narshu 1:cc2a9eb0bd55 461 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 462 XprLiteral<T>
narshu 1:cc2a9eb0bd55 463 > expr_type;
narshu 1:cc2a9eb0bd55 464 return XprVector<expr_type, Sz>(
narshu 1:cc2a9eb0bd55 465 expr_type(lhs.const_ref(), XprLiteral<T>(rhs)));
narshu 1:cc2a9eb0bd55 466 }
narshu 1:cc2a9eb0bd55 467
narshu 1:cc2a9eb0bd55 468
narshu 1:cc2a9eb0bd55 469 /**
narshu 1:cc2a9eb0bd55 470 * \fn pow(const Vector<std::complex<T>, Sz>& lhs, int rhs)
narshu 1:cc2a9eb0bd55 471 * \ingroup _binary_function
narshu 1:cc2a9eb0bd55 472 */
narshu 1:cc2a9eb0bd55 473 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 474 inline
narshu 1:cc2a9eb0bd55 475 XprVector<
narshu 1:cc2a9eb0bd55 476 XprBinOp<
narshu 1:cc2a9eb0bd55 477 Fcnl_pow<std::complex<T>, int>,
narshu 1:cc2a9eb0bd55 478 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 479 XprLiteral<int>
narshu 1:cc2a9eb0bd55 480 >,
narshu 1:cc2a9eb0bd55 481 Sz
narshu 1:cc2a9eb0bd55 482 >
narshu 1:cc2a9eb0bd55 483 pow(const Vector<std::complex<T>, Sz>& lhs, int rhs) {
narshu 1:cc2a9eb0bd55 484 typedef XprBinOp<
narshu 1:cc2a9eb0bd55 485 Fcnl_pow<std::complex<T>, int>,
narshu 1:cc2a9eb0bd55 486 VectorConstReference<std::complex<T>, Sz>,
narshu 1:cc2a9eb0bd55 487 XprLiteral<int>
narshu 1:cc2a9eb0bd55 488 > expr_type;
narshu 1:cc2a9eb0bd55 489 return XprVector<expr_type, Sz>(
narshu 1:cc2a9eb0bd55 490 expr_type(lhs.const_ref(), XprLiteral<int>(rhs)));
narshu 1:cc2a9eb0bd55 491 }
narshu 1:cc2a9eb0bd55 492
narshu 1:cc2a9eb0bd55 493
narshu 1:cc2a9eb0bd55 494 /**
narshu 1:cc2a9eb0bd55 495 * \fn polar(const Vector<T, Sz>& lhs, const T& rhs)
narshu 1:cc2a9eb0bd55 496 * \ingroup _binary_function
narshu 1:cc2a9eb0bd55 497 */
narshu 1:cc2a9eb0bd55 498 template<class T, std::size_t Sz>
narshu 1:cc2a9eb0bd55 499 inline
narshu 1:cc2a9eb0bd55 500 XprVector<
narshu 1:cc2a9eb0bd55 501 XprBinOp<
narshu 1:cc2a9eb0bd55 502 Fcnl_polar<T, T>,
narshu 1:cc2a9eb0bd55 503 VectorConstReference<T, Sz>,
narshu 1:cc2a9eb0bd55 504 XprLiteral<T>
narshu 1:cc2a9eb0bd55 505 >,
narshu 1:cc2a9eb0bd55 506 Sz
narshu 1:cc2a9eb0bd55 507 >
narshu 1:cc2a9eb0bd55 508 polar(const Vector<T, Sz>& lhs, const T& rhs) {
narshu 1:cc2a9eb0bd55 509 typedef XprBinOp<
narshu 1:cc2a9eb0bd55 510 Fcnl_polar<T, T>,
narshu 1:cc2a9eb0bd55 511 VectorConstReference<T, Sz>,
narshu 1:cc2a9eb0bd55 512 XprLiteral<T>
narshu 1:cc2a9eb0bd55 513 > expr_type;
narshu 1:cc2a9eb0bd55 514 return XprVector<expr_type, Sz>(
narshu 1:cc2a9eb0bd55 515 expr_type(lhs.const_ref(), XprLiteral<T>(rhs)));
narshu 1:cc2a9eb0bd55 516 }
narshu 1:cc2a9eb0bd55 517 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
narshu 1:cc2a9eb0bd55 518
narshu 1:cc2a9eb0bd55 519 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
narshu 1:cc2a9eb0bd55 520 // to be written (atan2)
narshu 1:cc2a9eb0bd55 521 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
narshu 1:cc2a9eb0bd55 522
narshu 1:cc2a9eb0bd55 523
narshu 1:cc2a9eb0bd55 524 } // namespace tvmet
narshu 1:cc2a9eb0bd55 525
narshu 1:cc2a9eb0bd55 526 #endif // TVMET_VECTOR_BINARY_FUNCTIONS_H
narshu 1:cc2a9eb0bd55 527
narshu 1:cc2a9eb0bd55 528 // Local Variables:
narshu 1:cc2a9eb0bd55 529 // mode:C++
narshu 1:cc2a9eb0bd55 530 // tab-width:8
narshu 1:cc2a9eb0bd55 531 // End: