Browse Source

Remove CL_REQUIRE/CL_PROVIDE(cl_I_factorial) as it's not really necessary.

factorial() is the only function which uses fakul_table[] array, so move
it into that function in order to avoid possible static initialization
order problems.
master
Alexei Sheplyakov 17 years ago
parent
commit
58de93cddb
  1. 1
      include/cln/integer.h
  2. 7
      src/integer/misc/combin/cl_I_factorial.cc

1
include/cln/integer.h

@ -391,7 +391,6 @@ extern const cl_I expt_pos (const cl_I& x, const cl_I& y);
// Fakultät (! n), wo n Fixnum >=0 ist. Ergebnis Integer. // Fakultät (! n), wo n Fixnum >=0 ist. Ergebnis Integer.
extern const cl_I factorial (uintL n); extern const cl_I factorial (uintL n);
//CL_REQUIRE(cl_I_factorial)
// Double factorial (!! n), with n Fixnum >=0. Returns integer. // Double factorial (!! n), with n Fixnum >=0. Returns integer.
extern const cl_I doublefactorial (uintL n); extern const cl_I doublefactorial (uintL n);

7
src/integer/misc/combin/cl_I_factorial.cc

@ -3,8 +3,6 @@
// General includes. // General includes.
#include "cl_sysdep.h" #include "cl_sysdep.h"
CL_PROVIDE(cl_I_factorial)
// Specification. // Specification.
#include "cln/integer.h" #include "cln/integer.h"
@ -30,6 +28,8 @@ namespace cln {
// vermeidet, daß oft große Zahlen mit ganz kleinen Zahlen multipliziert // vermeidet, daß oft große Zahlen mit ganz kleinen Zahlen multipliziert
// werden. // werden.
const cl_I factorial (uintL n) // assume n >= 0 small
{
static uintV const fakul_table [] = { static uintV const fakul_table [] = {
1, 1,
1UL, 1UL,
@ -93,8 +93,6 @@ static uintV const fakul_table [] = {
#endif #endif
}; };
const cl_I factorial (uintL n) // assume n >= 0 small
{
if (n < sizeof(fakul_table)/sizeof(cl_I)) if (n < sizeof(fakul_table)/sizeof(cl_I))
{ return UV_to_I(fakul_table[n]); } { return UV_to_I(fakul_table[n]); }
else else
@ -124,4 +122,3 @@ const cl_I factorial (uintL n) // assume n >= 0 small
} // namespace cln } // namespace cln
CL_PROVIDE_END(cl_I_factorial)
Loading…
Cancel
Save