00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "num_math.h"
00018
00019
00020 namespace NUM
00021 {
00022
00023 template<typename T>static volatile void _CME_add1(T x,volatile T *res);
00024
00025 template<typename T>static volatile T _ComputeMachEps1()
00026 {
00027 volatile T e=1.0e-5,pe=e,e1;
00028 do {
00029 pe=e;
00030 e/=1.5;
00031 _CME_add1(e,&e1);
00032 } while(e1>1.0);
00033
00034
00035 return(pe);
00036 }
00037
00038 template<typename T>static volatile void _CME_add1(T x,volatile T *res)
00039 {
00040 *res=1.0+x;
00041 }
00042
00043
00044 template<typename T>static T _ComputeMachEps1_Prec()
00045 {
00046 register T e=1.0e-5,pe=e;
00047 while(1.0+e>1.0)
00048 { pe=e; e/=1.5; }
00049
00050 return(pe);
00051 }
00052
00053
00054
00055 const FPConst<dbl> fpconst_dbl=
00056 {
00057 INIT_FIELD(macheps1) _ComputeMachEps1<dbl>(),
00058 INIT_FIELD(sqrt_macheps1) sqrt(_ComputeMachEps1<dbl>()),
00059 INIT_FIELD(macheps1_prec) _ComputeMachEps1_Prec<dbl>()
00060 };
00061
00062 const FPConst<flt> fpconst_flt=
00063 {
00064 INIT_FIELD(macheps1) _ComputeMachEps1<flt>(),
00065 INIT_FIELD(sqrt_macheps1) sqrt(_ComputeMachEps1<flt>()),
00066 INIT_FIELD(macheps1_prec) _ComputeMachEps1_Prec<flt>()
00067 };
00068
00069 }