Browse Source

Get rid of CL_REQUIRE/CL_PROVIDE(cl_F_catalanconst_var).

Turn cl_[SDFL]F_catalanconst global variables into functions (which return
a reference to the static value) in order to avoid static initialization
order problems.
master
Alexei Sheplyakov 16 years ago
parent
commit
caa1a38330
  1. 3
      include/cln/float.h
  2. 6
      src/float/transcendental/cl_F_catalanconst.cc
  3. 6
      src/float/transcendental/cl_F_catalanconst_def.cc
  4. 6
      src/float/transcendental/cl_F_catalanconst_f.cc
  5. 36
      src/float/transcendental/cl_F_catalanconst_var.cc
  6. 8
      src/float/transcendental/cl_F_tran.h
  7. 12
      src/float/transcendental/cl_LF_catalanconst.cc

3
include/cln/float.h

@ -691,9 +691,6 @@ extern const cl_F catalanconst (float_format_t f);
// catalanconst() liefert die Catalansche Konstante im Default-Float-Format.
extern const cl_F catalanconst (void);
//CL_REQUIRE(cl_F_catalanconst_var)
// zeta(s) returns the Riemann zeta function at s>1.
extern const cl_F zeta (int s, const cl_F& y);
extern const cl_F zeta (int s, float_format_t f);

6
src/float/transcendental/cl_F_catalanconst.cc

@ -18,9 +18,9 @@ namespace cln {
const cl_F catalanconst (const cl_F& y)
{
floattypecase(y
, return cl_SF_catalanconst;
, return cl_FF_catalanconst;
, return cl_DF_catalanconst;
, return cl_SF_catalanconst();
, return cl_FF_catalanconst();
, return cl_DF_catalanconst();
, return catalanconst(TheLfloat(y)->len);
);
}

6
src/float/transcendental/cl_F_catalanconst_def.cc

@ -17,9 +17,9 @@ namespace cln {
const cl_F catalanconst (void)
{
floatformatcase(default_float_format
, return cl_SF_catalanconst;
, return cl_FF_catalanconst;
, return cl_DF_catalanconst;
, return cl_SF_catalanconst();
, return cl_FF_catalanconst();
, return cl_DF_catalanconst();
, return catalanconst(len);
);
}

6
src/float/transcendental/cl_F_catalanconst_f.cc

@ -17,9 +17,9 @@ namespace cln {
const cl_F catalanconst (float_format_t f)
{
floatformatcase((uintC)f
, return cl_SF_catalanconst;
, return cl_FF_catalanconst;
, return cl_DF_catalanconst;
, return cl_SF_catalanconst();
, return cl_FF_catalanconst();
, return cl_DF_catalanconst();
, return catalanconst(len);
);
}

36
src/float/transcendental/cl_F_catalanconst_var.cc

@ -3,8 +3,6 @@
// General includes.
#include "cl_sysdep.h"
CL_PROVIDE(cl_F_catalanconst_var)
// Specification.
#include "cl_F_tran.h"
@ -18,20 +16,36 @@ CL_PROVIDE(cl_F_catalanconst_var)
namespace cln {
// Mantisse der Catalanschen Konstante :
static const uintD catalanconst_mantisse [64/intDsize] =
#include "cl_F_catalanconst_var.h"
cl_LF cl_LF_catalanconst = encode_LF_array(0,0,catalanconst_mantisse,64/intDsize);
cl_LF& cl_LF_catalanconst()
{
// Mantisse der Catalanschen Konstante :
static const uintD catalanconst_mantisse [64/intDsize] =
#include "cl_F_catalanconst_var.h"
static cl_LF val = encode_LF_array(0,0,catalanconst_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_catalanconst = cl_LF_to_SF(cl_LF_catalanconst);
const cl_FF cl_FF_catalanconst = cl_LF_to_FF(cl_LF_catalanconst);
const cl_DF cl_DF_catalanconst = cl_LF_to_DF(cl_LF_catalanconst);
const cl_SF& cl_SF_catalanconst()
{
static const cl_SF val = cl_LF_to_SF(cl_LF_catalanconst());
return val;
}
const cl_DF& cl_DF_catalanconst()
{
static const cl_DF val = cl_LF_to_DF(cl_LF_catalanconst());
return val;
}
const cl_FF& cl_FF_catalanconst()
{
static const cl_FF val = cl_LF_to_FF(cl_LF_catalanconst());
return val;
}
} // namespace cln
CL_PROVIDE_END(cl_F_catalanconst_var)

8
src/float/transcendental/cl_F_tran.h

@ -133,10 +133,10 @@ extern cl_LF& cl_LF_eulerconst(); // as long as it has ever been computed
extern const cl_LF eulerconst (uintC len); // computes it even further
// Catalansche Konstante.
extern const cl_SF cl_SF_catalanconst;
extern const cl_FF cl_FF_catalanconst;
extern const cl_DF cl_DF_catalanconst;
extern cl_LF cl_LF_catalanconst; // as long as it has ever been computed
extern const cl_SF& cl_SF_catalanconst();
extern const cl_FF& cl_FF_catalanconst();
extern const cl_DF& cl_DF_catalanconst();
extern cl_LF& cl_LF_catalanconst(); // as long as it has ever been computed
extern const cl_LF catalanconst (uintC len); // computes it even further
// Zeta-Funktion für s>1 ganzzahlig.

12
src/float/transcendental/cl_LF_catalanconst.cc

@ -300,13 +300,13 @@ const cl_LF compute_catalanconst (uintC len)
const cl_LF catalanconst (uintC len)
{
var uintC oldlen = TheLfloat(cl_LF_catalanconst)->len; // vorhandene Länge
var uintC oldlen = TheLfloat(cl_LF_catalanconst())->len; // vorhandene Länge
if (len < oldlen)
return shorten(cl_LF_catalanconst,len);
return shorten(cl_LF_catalanconst(),len);
if (len == oldlen)
return cl_LF_catalanconst;
return cl_LF_catalanconst();
// TheLfloat(cl_LF_catalanconst)->len um mindestens einen konstanten Faktor
// TheLfloat(cl_LF_catalanconst())->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
@ -314,8 +314,8 @@ const cl_LF catalanconst (uintC len)
newlen = oldlen;
// gewünschte > vorhandene Länge -> muß nachberechnen:
cl_LF_catalanconst = compute_catalanconst(newlen);
return (len < newlen ? shorten(cl_LF_catalanconst,len) : cl_LF_catalanconst);
cl_LF_catalanconst() = compute_catalanconst(newlen);
return (len < newlen ? shorten(cl_LF_catalanconst(),len) : cl_LF_catalanconst());
}
} // namespace cln
Loading…
Cancel
Save