]> www.ginac.de Git - cln.git/blobdiff - src/float/transcendental/cl_LF_ratsumseries_pqd.cc
Make some functions more memory efficient:
[cln.git] / src / float / transcendental / cl_LF_ratsumseries_pqd.cc
index 891c5b4cddab160333e4cd7703a919877ee1bbf8..a47db3a91c196bc5287bd7345006e27a0fec0aa8 100644 (file)
@@ -9,16 +9,31 @@
 
 // Implementation.
 
-#include "cl_lfloat.h"
-#include "cl_integer.h"
-#include "cl_abort.h"
+#include "cln/lfloat.h"
+#include "cln/integer.h"
+#include "cln/real.h"
 #include "cl_LF.h"
 
-const cl_LF eval_pqd_series (uintL N, cl_pqd_series_term* args, uintC len)
+namespace cln {
+
+const cl_LF eval_pqd_series (uintC N, cl_pqd_series_term* args, uintC len)
+{
+       if (N==0)
+               return cl_I_to_LF(0,len);
+       var cl_pqd_series_result<cl_I> sums;
+       eval_pqd_series_aux(N,args,sums);
+       // Instead of computing  fsum = T/Q  and  gsum = V/(D*Q)
+       // and then dividing them, to compute  gsum/fsum, we save two
+       // divisions by computing  V/(D*T).
+       return
+         cl_I_to_LF(sums.V,len) / The(cl_LF)(sums.D * cl_I_to_LF(sums.T,len));
+}
+
+const cl_LF eval_pqd_series (uintC N, cl_pqd_series_stream& args, uintC len)
 {
        if (N==0)
                return cl_I_to_LF(0,len);
-       var cl_pqd_series_result sums;
+       var cl_pqd_series_result<cl_I> sums;
        eval_pqd_series_aux(N,args,sums);
        // Instead of computing  fsum = T/Q  and  gsum = V/(D*Q)
        // and then dividing them, to compute  gsum/fsum, we save two
@@ -26,3 +41,18 @@ const cl_LF eval_pqd_series (uintL N, cl_pqd_series_term* args, uintC len)
        return
          cl_I_to_LF(sums.V,len) / The(cl_LF)(sums.D * cl_I_to_LF(sums.T,len));
 }
+
+const cl_LF eval_pqd_series (uintC N, cl_pqd_series_stream& args, uintC len, uintC trunclen)
+{
+       if (N==0)
+               return cl_I_to_LF(0,len);
+       var cl_pqd_series_result<cl_R> sums;
+       eval_pqd_series_aux(N,args,sums,trunclen);
+       // Instead of computing  fsum = T/Q  and  gsum = V/(D*Q)
+       // and then dividing them, to compute  gsum/fsum, we save two
+       // divisions by computing  V/(D*T).
+       return
+         cl_R_to_LF(sums.V,len) / The(cl_LF)(sums.D * cl_R_to_LF(sums.T,len));
+}
+
+}  // namespace cln