]> www.ginac.de Git - cln.git/commitdiff
Remove CL_REQUIRE/CL_PROVIDE(cl_I_factorial) as it's not really necessary.
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Thu, 21 Aug 2008 11:58:06 +0000 (15:58 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Wed, 27 Aug 2008 04:41:06 +0000 (08:41 +0400)
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.

include/cln/integer.h
src/integer/misc/combin/cl_I_factorial.cc

index 2aaf9135475cdbd6069c449457c76b1ca1e7dd8d..081caf2659541d17198fd6e2795c9028463040d4 100644 (file)
@@ -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.
 extern const cl_I factorial (uintL n);
-//CL_REQUIRE(cl_I_factorial)
 
 // Double factorial (!! n), with n Fixnum >=0.  Returns integer.
 extern const cl_I doublefactorial (uintL n);
index 520519a55e29628eddac4ec629cc95be50075133..4e7917c68c2c68186ec28b5a468890a5d72e9717 100644 (file)
@@ -3,8 +3,6 @@
 // General includes.
 #include "cl_sysdep.h"
 
-CL_PROVIDE(cl_I_factorial)
-
 // Specification.
 #include "cln/integer.h"
 
@@ -30,7 +28,9 @@ namespace cln {
   //   vermeidet, daß oft große Zahlen mit ganz kleinen Zahlen multipliziert
   //   werden.
 
-static uintV const fakul_table [] = {
+const cl_I factorial (uintL n) // assume n >= 0 small
+{
+       static uintV const fakul_table [] = {
         1,
         1UL,
         1UL*2,
@@ -91,10 +91,8 @@ static uintV const fakul_table [] = {
         #endif
         #endif
         #endif
-};
+       };
 
-const cl_I factorial (uintL n) // assume n >= 0 small
-{
       if (n < sizeof(fakul_table)/sizeof(cl_I))
         { return UV_to_I(fakul_table[n]); }
         else
@@ -124,4 +122,3 @@ const cl_I factorial (uintL n) // assume n >= 0 small
 
 }  // namespace cln
 
-CL_PROVIDE_END(cl_I_factorial)