]> www.ginac.de Git - cln.git/blobdiff - src/float/random/cl_F_random.cc
2006-04-25 Bruno Haible <bruno@clisp.org>
[cln.git] / src / float / random / cl_F_random.cc
index d37fe6580b3cc5f2ae40942881795832b6b4e429..80cb9a8835e2ff56c9c21a2c54d6f5977cd463bc 100644 (file)
@@ -4,7 +4,7 @@
 #include "cl_sysdep.h"
 
 // Specification.
-#include "cl_float.h"
+#include "cln/float.h"
 
 
 // Implementation.
 #include "cl_DS.h"
 #include "cl_I.h"
 
-const cl_F random_F (cl_random_state& randomstate, const cl_F& n)
+namespace cln {
+
+const cl_F random_F (random_state& randomstate, const cl_F& n)
 {
-       var uintL d = float_digits(n); // d = (float-digits n) > 0
+       var uintC d = float_digits(n); // d = (float-digits n) > 0
        // Bilde neue UDS mit d Zufallsbits:
        CL_ALLOCA_STACK;
-       var uintL len = ceiling(d,intDsize);
+       var uintC len = ceiling(d,intDsize);
        var uintD* MSDptr;
        num_stack_alloc_1(len,MSDptr=,);
        random_UDS(randomstate,MSDptr,len); // len (>0) Zufallsdigits
@@ -28,10 +30,12 @@ const cl_F random_F (cl_random_state& randomstate, const cl_F& n)
        var cl_I mant = UDS_to_I(MSDptr,len);
        // Bilde  Zufalls-Float zwischen 0 und 1
        //        = (scale-float (float Zufalls-Integer,d_Bits n) (- d)) :
-       var cl_F result = scale_float(cl_float(mant,n),-(sintL)d) * n;
+       var cl_F result = scale_float(cl_float(mant,n),-(sintC)d) * n;
        // result ist ein Zufalls-Float >=0, <=n.
        if (result == n)
                // falls (durch Rundung) result=n, durch 0 ersetzen:
                { result = cl_float(0,result); }
        return result;
 }
+
+}  // namespace cln