diff --git a/include/cln/float.h b/include/cln/float.h index 48a83b8..4f25dc0 100644 --- a/include/cln/float.h +++ b/include/cln/float.h @@ -636,8 +636,6 @@ extern const cl_F exp1 (float_format_t f); // exp1() liefert die Zahl e = exp(1) im Default-Float-Format. extern const cl_F exp1 (void); -//CL_REQUIRE(cl_F_exp1_var) - // ln(x) liefert zu einem Float x>0 die Zahl ln(x). extern const cl_F ln (const cl_F& x); diff --git a/src/float/transcendental/cl_F_exp1.cc b/src/float/transcendental/cl_F_exp1.cc index 96fe892..08ef3d7 100644 --- a/src/float/transcendental/cl_F_exp1.cc +++ b/src/float/transcendental/cl_F_exp1.cc @@ -18,9 +18,9 @@ namespace cln { const cl_F exp1 (const cl_F& y) { floattypecase(y - , return cl_SF_exp1; - , return cl_FF_exp1; - , return cl_DF_exp1; + , return cl_SF_exp1(); + , return cl_FF_exp1(); + , return cl_DF_exp1(); , return exp1(TheLfloat(y)->len); ); } diff --git a/src/float/transcendental/cl_F_exp1_def.cc b/src/float/transcendental/cl_F_exp1_def.cc index ee74b05..cc50f69 100644 --- a/src/float/transcendental/cl_F_exp1_def.cc +++ b/src/float/transcendental/cl_F_exp1_def.cc @@ -17,9 +17,9 @@ namespace cln { const cl_F exp1 (void) { floatformatcase(default_float_format - , return cl_SF_exp1; - , return cl_FF_exp1; - , return cl_DF_exp1; + , return cl_SF_exp1(); + , return cl_FF_exp1(); + , return cl_DF_exp1(); , return exp1(len); ); } diff --git a/src/float/transcendental/cl_F_exp1_f.cc b/src/float/transcendental/cl_F_exp1_f.cc index 1e18b6d..aa8c451 100644 --- a/src/float/transcendental/cl_F_exp1_f.cc +++ b/src/float/transcendental/cl_F_exp1_f.cc @@ -17,9 +17,9 @@ namespace cln { const cl_F exp1 (float_format_t f) { floatformatcase((uintC)f - , return cl_SF_exp1; - , return cl_FF_exp1; - , return cl_DF_exp1; + , return cl_SF_exp1(); + , return cl_FF_exp1(); + , return cl_DF_exp1(); , return exp1(len); ); } diff --git a/src/float/transcendental/cl_F_exp1_var.cc b/src/float/transcendental/cl_F_exp1_var.cc index a68310d..e9b91b3 100644 --- a/src/float/transcendental/cl_F_exp1_var.cc +++ b/src/float/transcendental/cl_F_exp1_var.cc @@ -3,8 +3,6 @@ // General includes. #include "cl_sysdep.h" -CL_PROVIDE(cl_F_exp1_var) - // Specification. #include "cl_F_tran.h" @@ -18,20 +16,36 @@ CL_PROVIDE(cl_F_exp1_var) namespace cln { -// Mantisse von exp(1) : - static const uintD exp1_mantisse [64/intDsize] = - #include "cl_F_exp1_var.h" - -cl_LF cl_LF_exp1 = encode_LF_array(0,2,exp1_mantisse,64/intDsize); +cl_LF& cl_LF_exp1() +{ + // Mantisse von exp(1) : + static const uintD exp1_mantisse [64/intDsize] = + #include "cl_F_exp1_var.h" + static cl_LF val = encode_LF_array(0,2,exp1_mantisse,64/intDsize); + return val; +} // Problem: If someone changes free_hook, the destructor of this // will call the new hook, passing it some pointer obtained by the old // malloc_hook. ?? -const cl_SF cl_SF_exp1 = cl_LF_to_SF(cl_LF_exp1); -const cl_FF cl_FF_exp1 = cl_LF_to_FF(cl_LF_exp1); -const cl_DF cl_DF_exp1 = cl_LF_to_DF(cl_LF_exp1); +const cl_SF& cl_SF_exp1() +{ + static const cl_SF val = cl_LF_to_SF(cl_LF_exp1()); + return val; +} + +const cl_FF& cl_FF_exp1() +{ + static const cl_FF val = cl_LF_to_FF(cl_LF_exp1()); + return val; +} + +const cl_DF& cl_DF_exp1() +{ + static const cl_DF val = cl_LF_to_DF(cl_LF_exp1()); + return val; +} } // namespace cln -CL_PROVIDE_END(cl_F_exp1_var) diff --git a/src/float/transcendental/cl_F_tran.h b/src/float/transcendental/cl_F_tran.h index b91d00c..06395bc 100644 --- a/src/float/transcendental/cl_F_tran.h +++ b/src/float/transcendental/cl_F_tran.h @@ -114,10 +114,10 @@ extern const cl_F cl_ln10 (const cl_F& y); extern const cl_F cl_ln10 (float_format_t f); // e = exp(1). -extern const cl_SF cl_SF_exp1; -extern const cl_FF cl_FF_exp1; -extern const cl_DF cl_DF_exp1; -extern cl_LF cl_LF_exp1; // as long as it has ever been computed +extern const cl_SF& cl_SF_exp1(); +extern const cl_FF& cl_FF_exp1(); +extern const cl_DF& cl_DF_exp1(); +extern cl_LF& cl_LF_exp1(); // as long as it has ever been computed extern const cl_LF exp1 (uintC len); // computes it even further // expx(x) liefert zu einem Float x (betragsmäßig <1) exp(x) als Float. diff --git a/src/float/transcendental/cl_LF_exp1.cc b/src/float/transcendental/cl_LF_exp1.cc index 286fad1..70f79cc 100644 --- a/src/float/transcendental/cl_LF_exp1.cc +++ b/src/float/transcendental/cl_LF_exp1.cc @@ -78,13 +78,13 @@ const cl_LF compute_exp1 (uintC len) const cl_LF exp1 (uintC len) { - var uintC oldlen = TheLfloat(cl_LF_exp1)->len; // vorhandene Länge + var uintC oldlen = TheLfloat(cl_LF_exp1())->len; // vorhandene Länge if (len < oldlen) - return shorten(cl_LF_exp1,len); + return shorten(cl_LF_exp1(),len); if (len == oldlen) - return cl_LF_exp1; + return cl_LF_exp1(); - // TheLfloat(cl_LF_exp1)->len um mindestens einen konstanten Faktor + // TheLfloat(cl_LF_exp1())->len um mindestens einen konstanten Faktor // > 1 wachsen lassen, damit es nicht zu häufig nachberechnet wird: var uintC newlen = len; oldlen += floor(oldlen,2); // oldlen * 3/2 @@ -92,8 +92,8 @@ const cl_LF exp1 (uintC len) newlen = oldlen; // gewünschte > vorhandene Länge -> muß nachberechnen: - cl_LF_exp1 = compute_exp1(newlen); // (exp 1) - return (len < newlen ? shorten(cl_LF_exp1,len) : cl_LF_exp1); + cl_LF_exp1() = compute_exp1(newlen); // (exp 1) + return (len < newlen ? shorten(cl_LF_exp1(),len) : cl_LF_exp1()); } } // namespace cln