00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef LASS_GUARDIAN_OF_INCLUSION_NUM_BASIC_OPS_H
00051 #define LASS_GUARDIAN_OF_INCLUSION_NUM_BASIC_OPS_H
00052
00053 #include "num_common.h"
00054 #include <cmath>
00055
00056
00057
00058
00059 #if LASS_PLATFORM_TYPE == LASS_PLATFORM_TYPE_CYGWIN && defined(log2)
00060 # undef log2
00061 namespace std
00062 {
00063 template <typename T> inline T log2(T x) { return std::log(x) / T(M_LN2); }
00064 }
00065 #endif
00066
00067 namespace lass
00068 {
00069 namespace num
00070 {
00071
00072
00073
00074 template <typename T> inline T abs(const T& x);
00075 template <typename T> inline T sign(const T& x);
00076 template <typename T> inline T sqr(const T& x);
00077 template <typename T> inline T inv(const T& x);
00078 template <typename T> inline T cubic(const T& x);
00079 template <typename T> inline T pow(const T& x, const T& p);
00080 template <typename T> inline T log2(const T& x);
00081 template <typename T> inline T log10(const T& x);
00082 template <typename T> inline T norm(const T& x);
00083 template <typename T> inline T conj(const T& x);
00084 template <typename T> inline const T& clamp(const T& x, const T& min, const T& max);
00085 template <typename T> inline T lerp(const T& a, const T& b, const T& f);
00086
00087 template <typename T> inline void inpabs(T& x);
00088 template <typename T> inline void inpsign(T& x);
00089 template <typename T> inline void inpinv(T& x);
00090 template <typename T> inline void inpsqrt(T& x);
00091 template <typename T> inline void inpsqr(T& x);
00092 template <typename T> inline void inpcubic(T& x);
00093 template <typename T> inline void inppow(T& x, const T& p);
00094 template <typename T> inline void inpexp(T& x);
00095 template <typename T> inline void inplog(T& x);
00096 template <typename T> inline void inplog2(T& x);
00097 template <typename T> inline void inplog10(T& x);
00098 template <typename T> inline void inpcos(T& x);
00099 template <typename T> inline void inpsin(T& x);
00100 template <typename T> inline void inptan(T& x);
00101 template <typename T> inline void inpacos(T& x);
00102 template <typename T> inline void inpasin(T& x);
00103 template <typename T> inline void inpatan(T& x);
00104 template <typename T> inline void inpatan2(T& x, const T& y);
00105 template <typename T> inline void inpfloor(T& x);
00106 template <typename T> inline void inpceil(T& x);
00107 template <typename T> inline void inpround(T& x);
00108 template <typename T> inline void inpfractional(T& x);
00109 template <typename T> inline void inpdiv(T& x, const T& d);
00110 template <typename T> inline void inpmod(T& x, const T& d);
00111 template <typename T> inline void inpclamp(T& x, const T& min, const T& max);
00112 template <typename T> inline void compnorm(const T& x, T& y);
00113 template <typename T> inline void compinv(const T& x, T& y);
00114
00115 template<typename T,typename f> inline T applyFunction(const T& x, f func );
00116
00117
00118
00119
00120
00121 inline float abs(float x);
00122 inline float inv(float x);
00123 inline float sqrt(float x);
00124 inline float pow(float x, float p);
00125 inline float exp(float x);
00126 inline float log(float x);
00127 inline float log2(float x);
00128 inline float log10(float x);
00129 inline float cos(float x);
00130 inline float sin(float x);
00131 inline float tan(float x);
00132 inline float acos(float x);
00133 inline float asin(float x);
00134 inline float atan(float x);
00135 inline float atan2(float y, float x);
00136 inline float sinc(float x);
00137 inline float floor(float x);
00138 inline float ceil(float x);
00139 inline float round(float x);
00140 inline float fractional(float x);
00141 inline float div(float x, float d);
00142 inline float mod(float x, float d);
00143
00144 inline float fastSin(float x);
00145
00146
00147
00148
00149
00150 inline double abs(double x);
00151 inline double inv(double x);
00152 inline double sqrt(double x);
00153 inline double pow(double x, double p);
00154 inline double exp(double x);
00155 inline double log(double x);
00156 inline double log2(double x);
00157 inline double log10(double x);
00158 inline double cos(double x);
00159 inline double sin(double x);
00160 inline double tan(double x);
00161 inline double acos(double x);
00162 inline double asin(double x);
00163 inline double atan(double x);
00164 inline double atan2(double y, double x);
00165 inline double sinc(double x);
00166 inline double floor(double x);
00167 inline double ceil(double x);
00168 inline double round(double x);
00169 inline double fractional(double x);
00170 inline double div(double x, double d);
00171 inline double mod(double x, double d);
00172
00173 inline double fastSin(double x);
00174
00175
00176
00177
00178
00179 inline long double abs(long double x);
00180 inline long double inv(long double x);
00181 inline long double sqrt(long double x);
00182 inline long double pow(long double x, long double p);
00183 inline long double exp(long double x);
00184 inline long double log(long double x);
00185 inline long double log2(long double x);
00186 inline long double log10(long double x);
00187 inline long double cos(long double x);
00188 inline long double sin(long double x);
00189 inline long double tan(long double x);
00190 inline long double acos(long double x);
00191 inline long double asin(long double x);
00192 inline long double atan(long double x);
00193 inline long double atan2(long double y, long double x);
00194 inline long double sinc(long double x);
00195 inline long double floor(long double x);
00196 inline long double ceil(long double x);
00197 inline long double round(long double x);
00198 inline long double fractional(long double x);
00199 inline long double div(long double x, long double d);
00200 inline long double mod(long double x, long double d);
00201
00202 inline long double fastSin(long double x);
00203
00204
00205
00206
00207
00208 inline char pow(char x, char p);
00209 inline char floor(char x);
00210 inline char ceil(char x);
00211 inline char round(char x);
00212 inline char fractional(char x);
00213 inline char div(char x, char p);
00214 inline char mod(char x, char p);
00215
00216 inline void inpabs(char& x);
00217 inline void inpfloor(char& x);
00218 inline void inpceil(char& x);
00219 inline void inpround(char& x);
00220 inline void inpfractional(char& x);
00221
00222 #ifdef LASS_CHAR_IS_SIGNED
00223
00224 inline char pow(char x, unsigned char p);
00225 inline char div(char x, unsigned char d);
00226 inline char mod(char x, unsigned char d);
00227
00228 #else
00229
00230 inline char abs(char x);
00231 inline char sign(char x);
00232
00233 #endif
00234
00235
00236
00237
00238
00239 inline signed char abs(signed char x);
00240 inline signed char pow(signed char x, signed char p);
00241 inline signed char pow(signed char x, unsigned char p);
00242 inline signed char floor(signed char x);
00243 inline signed char ceil(signed char x);
00244 inline signed char round(signed char x);
00245 inline signed char fractional(signed char x);
00246 inline signed char div(signed char x, signed char d);
00247 inline signed char div(signed char x, unsigned char d);
00248 inline signed char mod(signed char x, signed char d);
00249 inline signed char mod(signed char x, unsigned char d);
00250
00251 inline void inpfloor(signed char& x);
00252 inline void inpceil(signed char& x);
00253 inline void inpround(signed char& x);
00254 inline void inpfractional(signed char& x);
00255
00256
00257
00258 inline unsigned char abs(unsigned char x);
00259 inline unsigned char sign(unsigned char x);
00260 inline unsigned char pow(unsigned char x, unsigned char p);
00261 inline unsigned char floor(unsigned char x);
00262 inline unsigned char ceil(unsigned char x);
00263 inline unsigned char round(unsigned char x);
00264 inline unsigned char fractional(unsigned char x);
00265 inline unsigned char div(unsigned char x, unsigned char d);
00266 inline unsigned char mod(unsigned char x, unsigned char d);
00267
00268 inline void inpabs(unsigned char& x);
00269 inline void inpfloor(unsigned char& x);
00270 inline void inpceil(unsigned char& x);
00271 inline void inpround(unsigned char& x);
00272 inline void inpfractional(unsigned char& x);
00273
00274
00275
00276
00277
00278 inline signed short abs(signed short x);
00279 inline signed short pow(signed short x, signed short p);
00280 inline signed short pow(signed short x, unsigned short p);
00281 inline signed short floor(signed short x);
00282 inline signed short ceil(signed short x);
00283 inline signed short round(signed short x);
00284 inline signed short fractional(signed short x);
00285 inline signed short div(signed short x, signed short d);
00286 inline signed short div(signed short x, unsigned short d);
00287 inline signed short mod(signed short x, signed short d);
00288 inline signed short mod(signed short x, unsigned short d);
00289
00290 inline void inpfloor(signed short& x);
00291 inline void inpceil(signed short& x);
00292 inline void inpround(signed short& x);
00293 inline void inpfractional(signed short& x);
00294
00295
00296
00297 inline unsigned short abs(unsigned short x);
00298 inline unsigned short sign(unsigned short x);
00299 inline unsigned short pow(unsigned short x, unsigned short p);
00300 inline unsigned short floor(unsigned short x);
00301 inline unsigned short ceil(unsigned short x);
00302 inline unsigned short round(unsigned short x);
00303 inline unsigned short fractional(unsigned short x);
00304 inline unsigned short div(unsigned short x, unsigned short d);
00305 inline unsigned short mod(unsigned short x, unsigned short d);
00306
00307 inline void inpabs(unsigned short& x);
00308 inline void inpfloor(unsigned short& x);
00309 inline void inpceil(unsigned short& x);
00310 inline void inpround(unsigned short& x);
00311 inline void inpfractional(unsigned short& x);
00312
00313
00314
00315
00316
00317 inline signed int abs(signed int x);
00318 inline signed int pow(signed int x, signed int p);
00319 inline signed int pow(signed int x, unsigned int p);
00320 inline signed int floor(signed int x);
00321 inline signed int ceil(signed int x);
00322 inline signed int round(signed int x);
00323 inline signed int fractional(signed int x);
00324 inline signed int div(signed int x, signed int d);
00325 inline signed int div(signed int x, unsigned int d);
00326 inline signed int mod(signed int x, signed int d);
00327 inline signed int mod(signed int x, unsigned int d);
00328
00329 inline void inpfloor(signed int& x);
00330 inline void inpceil(signed int& x);
00331 inline void inpround(signed int& x);
00332 inline void inpfractional(signed int& x);
00333
00334
00335
00336 inline unsigned int abs(unsigned int x);
00337 inline unsigned int sign(unsigned int x);
00338 inline unsigned int pow(unsigned int x, unsigned int y);
00339 inline unsigned int floor(unsigned int x);
00340 inline unsigned int ceil(unsigned int x);
00341 inline unsigned int round(unsigned int x);
00342 inline unsigned int fractional(unsigned int x);
00343 inline unsigned int div(unsigned int x, unsigned int d);
00344 inline unsigned int mod(unsigned int x, unsigned int d);
00345
00346 inline void inpabs(unsigned int& x);
00347 inline void inpfloor(unsigned int& x);
00348 inline void inpceil(unsigned int& x);
00349 inline void inpround(unsigned int& x);
00350 inline void inpfractional(unsigned int& x);
00351
00352
00353
00354
00355
00356 inline signed long abs(signed long x);
00357 inline signed long pow(signed long x, signed long y);
00358 inline signed long pow(signed long x, unsigned long y);
00359 inline signed long floor(signed long x);
00360 inline signed long ceil(signed long x);
00361 inline signed long round(signed long x);
00362 inline signed long fractional(signed long x);
00363 inline signed long div(signed long x, signed long d);
00364 inline signed long div(signed long x, unsigned long d);
00365 inline signed long mod(signed long x, signed long d);
00366 inline signed long mod(signed long x, unsigned long d);
00367
00368 inline void inpfloor(signed long& x);
00369 inline void inpceil(signed long& x);
00370 inline void inpround(signed long& x);
00371 inline void inpfractional(signed long& x);
00372
00373
00374
00375 inline unsigned long abs(unsigned long x);
00376 inline unsigned long sign(unsigned long x);
00377 inline unsigned long pow(unsigned long x, unsigned long p);
00378 inline unsigned long floor(unsigned long x);
00379 inline unsigned long ceil(unsigned long x);
00380 inline unsigned long round(unsigned long x);
00381 inline unsigned long fractional(unsigned long x);
00382 inline unsigned long div(unsigned long x, unsigned long d);
00383 inline unsigned long mod(unsigned long x, unsigned long d);
00384
00385 inline void inpabs(unsigned long& x);
00386 inline void inpfloor(unsigned long& x);
00387 inline void inpceil(unsigned long& x);
00388 inline void inpround(unsigned long& x);
00389 inline void inpfractional(unsigned long& x);
00390
00391
00392
00393
00394
00395 template <typename T> inline std::complex<T> abs(const std::complex<T>& x);
00396 template <typename T> inline std::complex<T> inv(const std::complex<T>& x);
00397 template <typename T> inline std::complex<T> sqrt(const std::complex<T>& x);
00398 template <typename T> inline std::complex<T> pow(const std::complex<T>& x, const std::complex<T>& p);
00399 template <typename T> inline std::complex<T> exp(const std::complex<T>& x);
00400 template <typename T> inline std::complex<T> log(const std::complex<T>& x);
00401 template <typename T> inline std::complex<T> log2(const std::complex<T>& x);
00402 template <typename T> inline std::complex<T> log10(const std::complex<T>& x);
00403 template <typename T> inline std::complex<T> cos(const std::complex<T>& x);
00404 template <typename T> inline std::complex<T> sin(const std::complex<T>& x);
00405 template <typename T> inline std::complex<T> tan(const std::complex<T>& x);
00406 template <typename T> inline std::complex<T> atan(const std::complex<T>& x);
00407
00408 template <typename T> inline T norm(const std::complex<T>& x);
00409 template <typename T> inline std::complex<T> conj(const std::complex<T>& x);
00410
00411 #include "basic_ops.inl"
00412
00413 }
00414
00415 }
00416
00417 #endif