template_blas_basicmath.h
Go to the documentation of this file.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 #ifndef TEMPLATE_BLAS_BASICMATH_HEADER
00036 #define TEMPLATE_BLAS_BASICMATH_HEADER
00037
00038 #include <limits>
00039
00040 template<class Treal>
00041 Treal template_blas_fabs(Treal x);
00042
00043 template<class Treal>
00044 Treal template_blas_sqrt(Treal x);
00045
00046 template<class Treal>
00047 Treal template_blas_exp(Treal x);
00048
00049 template<class Treal>
00050 Treal template_blas_log(Treal x);
00051
00052 template<class Treal>
00053 Treal template_blas_erf(Treal x);
00054
00055 template<class Treal>
00056 Treal template_blas_erfc(Treal x);
00057
00058
00059
00060
00061
00062 template<class Treal>
00063 Treal template_blas_compute_pi_BBP(Treal dummy)
00064 {
00065 Treal epsilon = std::numeric_limits<Treal>::epsilon();
00066 Treal one_over_16 = (Treal)1 / (Treal)16;
00067 Treal one_over_16_to_pow_k = 1;
00068 Treal sum = 0;
00069 int k = 0;
00070 do
00071 {
00072 Treal factor =
00073 (Treal)4 / (Treal)(8*k + 1) -
00074 (Treal)2 / (Treal)(8*k + 4) -
00075 (Treal)1 / (Treal)(8*k + 5) -
00076 (Treal)1 / (Treal)(8*k + 6);
00077 sum += one_over_16_to_pow_k * factor;
00078 k++;
00079 one_over_16_to_pow_k *= one_over_16;
00080 }
00081 while(one_over_16_to_pow_k > epsilon);
00082 return sum;
00083 }
00084
00085
00086 #endif