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 #ifndef TEMPLATE_BLAS_BASICMATH_HEADER
00038 #define TEMPLATE_BLAS_BASICMATH_HEADER
00039
00040 #include "template_blas_num_limits.h"
00041
00042 template<class Treal>
00043 Treal template_blas_fabs(Treal x);
00044
00045 template<class Treal>
00046 Treal template_blas_sqrt(Treal x);
00047
00048 template<class Treal>
00049 Treal template_blas_exp(Treal x);
00050
00051 template<class Treal>
00052 Treal template_blas_log(Treal x);
00053
00054 template<class Treal>
00055 Treal template_blas_log10(Treal x);
00056
00057 template<class Treal>
00058 Treal template_blas_erf(Treal x);
00059
00060 template<class Treal>
00061 Treal template_blas_erfc(Treal x);
00062
00063 template<class Treal>
00064 Treal template_blas_sin(Treal x);
00065
00066 template<class Treal>
00067 Treal template_blas_cos(Treal x);
00068
00069 template<class Treal>
00070 Treal template_blas_pow(Treal x, Treal y);
00071
00072
00073
00074
00075
00076 template<class Treal>
00077 Treal template_blas_compute_pi_BBP(Treal dummy)
00078 {
00079 Treal epsilon = template_blas_get_machine_epsilon<Treal>();
00080 Treal one_over_16 = (Treal)1 / (Treal)16;
00081 Treal one_over_16_to_pow_k = 1;
00082 Treal sum = 0;
00083 int k = 0;
00084 do
00085 {
00086 Treal factor =
00087 (Treal)4 / (Treal)(8*k + 1) -
00088 (Treal)2 / (Treal)(8*k + 4) -
00089 (Treal)1 / (Treal)(8*k + 5) -
00090 (Treal)1 / (Treal)(8*k + 6);
00091 sum += one_over_16_to_pow_k * factor;
00092 k++;
00093 one_over_16_to_pow_k *= one_over_16;
00094 }
00095 while(one_over_16_to_pow_k > epsilon);
00096 return sum;
00097 }
00098
00099
00100 #endif