1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #pragma once23 24 #include "[MathTypes.h]"25 #include "[MathNamespace.h]"26 27 #include <limits>28 #include <math.h>29 #include <float.h>30 31 #ifdef __GNUC__32 #define NOT_NECESSARILY_USED __attribute__ ((unused))33 #else34 #define NOT_NECESSARILY_USED35 #endif36 37 #if defined(_MSC_VER) || defined(EMSCRIPTEN)38 #define FLOAT_NAN ((float)std::numeric_limits<float>::quiet_NaN())39 #define FLOAT_INF ((float)std::numeric_limits<float>::infinity())40 #else41 #define FLOAT_NAN ((float)NAN)42 #define FLOAT_INF ((float)INFINITY)43 #endif44 45 [MATH_BEGIN_NAMESPACE]46 47 48 const float [NOT_NECESSARILY_USED] [recipSqrt2Pi] = (float)0.3989422804014326779399460599343818684758586311649346576659258296706579258993018385012523339073069364;49 50 const float [NOT_NECESSARILY_USED] [cos1] = (float)0.5403023058681397174009366074429766037323104206179222276700972553811003947744717645179518560871830893;51 52 const float [NOT_NECESSARILY_USED] [ln2] = (float)0.6931471805599453094172321214581765680755001343602552541206800094933936219696947156058633269964186875;53 54 const float [NOT_NECESSARILY_USED] [cbrt3] = (float)1.4422495703074083823216383107801095883918692534993505775464161945416875968299973398547554797056452567;55 56 const float [NOT_NECESSARILY_USED] [recipLn2] = (float)1.4426950408889634073599246810018921374266459541529859341354494069311092191811850798855266228935063444;57 58 const float [NOT_NECESSARILY_USED] [phi] = (float)1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911375;59 60 const float [NOT_NECESSARILY_USED] [ln10] = (float)2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983;61 62 const float [NOT_NECESSARILY_USED] [e] = (float)2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274;63 64 const float [NOT_NECESSARILY_USED] [pi] = (float)3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;65 66 const float [NOT_NECESSARILY_USED] [e2] = (float)7.3890560989306502272304274605750078131803155705518473240871278225225737960790577633843124850791217948;67 68 const float [NOT_NECESSARILY_USED] [eps] = (float)1[e]-5f;69 70 const float [NOT_NECESSARILY_USED] [inf] = [FLOAT_INF];71 72 const float [NOT_NECESSARILY_USED] [negInf] = -[FLOAT_INF];73 74 const float [NOT_NECESSARILY_USED] [nan] = [FLOAT_NAN];75 76 const float [NOT_NECESSARILY_USED] [floatMax] = FLT_MAX;77 78 const float [NOT_NECESSARILY_USED] [floatMin] = -FLT_MAX;79 80 81 template<u32 Base, u32 Power>82 class [PowT]83 {84 public:85 enum { [val] = Base * [PowT]<Base,Power-1>[::val] };86 };87 88 89 90 91 template<u32 Base>92 class [PowT]<Base, 1>93 {94 public:95 enum { [val] = Base };96 };97 98 99 100 template<int N>101 class [FactorialT]102 {103 public:104 enum { [val] = N * [FactorialT]<N-1>[::val] };105 };106 107 108 109 110 template<>111 class [FactorialT]<0>112 {113 public:114 enum { [val] = 1 };115 };116 117 118 119 template<int N, int K>120 class [CombinatorialT]121 {122 public:123 enum { [val] = [CombinatorialT]<N-1,K-1>[::val] + [CombinatorialT]<N-1,K>[::val] };124 };125 126 127 128 129 template<int N>130 class [CombinatorialT]<N, 0>131 {132 public:133 enum { [val] = 1 };134 };135 136 137 template<int N>138 class [CombinatorialT]<N, N>139 {140 public:141 enum { [val] = 1 };142 };143 144 145 [MATH_END_NAMESPACE] Go back to previous page