// Implementation.
-#include "cl_lfloat.h"
-#include "cl_integer.h"
-#include "cl_abort.h"
+#include "cln/lfloat.h"
+#include "cln/integer.h"
+#include "cln/abort.h"
#include "cl_LF.h"
+namespace cln {
+
// Subroutine.
// Evaluates S = sum(N1 <= n < N2, a(n)/b(n) * (p(N1)...p(n))/(q(N1)...q(n)))
// and returns P = p(N1)...p(N2-1), Q = q(N1)...q(N2-1), B = B(N1)...B(N2-1)
// and T = B*Q*S (all integers). On entry N1 < N2.
// P will not be computed if a NULL pointer is passed.
-static void eval_pq_series_aux (uintL N1, uintL N2,
+static void eval_pq_series_aux (uintC N1, uintC N2,
const cl_pq_series& args,
cl_I* P, cl_I* Q, cl_I* T)
{
break;
}
default: {
- var uintL Nm = (N1+N2)/2; // midpoint
+ var uintC Nm = (N1+N2)/2; // midpoint
// Compute left part.
var cl_I LP, LQ, LT;
eval_pq_series_aux(N1,Nm,args,&LP,&LQ,<);
}
}
-static void eval_pqs_series_aux (uintL N1, uintL N2,
+static void eval_pqs_series_aux (uintC N1, uintC N2,
const cl_pq_series& args,
- cl_I* P, cl_I* Q, uintL* QS, cl_I* T)
+ cl_I* P, cl_I* Q, uintC* QS, cl_I* T)
{
switch (N2 - N1) {
case 0:
break;
}
default: {
- var uintL Nm = (N1+N2)/2; // midpoint
+ var uintC Nm = (N1+N2)/2; // midpoint
// Compute left part.
var cl_I LP, LQ, LT;
- var uintL LQS;
+ var uintC LQS;
eval_pqs_series_aux(N1,Nm,args,&LP,&LQ,&LQS,<);
// Compute right part.
var cl_I RP, RQ, RT;
- var uintL RQS;
+ var uintC RQS;
eval_pqs_series_aux(Nm,N2,args,(P?&RP:(cl_I*)0),&RQ,&RQS,&RT);
// Put together partial results.
if (P) { *P = LP*RP; }
}
}
-const cl_LF eval_rational_series (uintL N, const cl_pq_series& args, uintC len)
+const cl_LF eval_rational_series (uintC N, const cl_pq_series& args, uintC len)
{
if (N==0)
return cl_I_to_LF(0,len);
// Split qv[n] into qv[n]*2^qsv[n].
{
var cl_I* qp = args.qv;
- var uintL* qsp = args.qsv;
- for (var uintL n = 0; n < N; n++, qp++, qsp++) {
+ var uintC* qsp = args.qsv;
+ for (var uintC n = 0; n < N; n++, qp++, qsp++) {
// Pull out maximal power of 2 out of *qp = args.qv[n].
- var uintL qs = 0;
+ var uintC qs = 0;
if (!zerop(*qp)) {
qs = ord2(*qp);
if (qs > 0)
}
}
// Main computation.
- var uintL QS;
+ var uintC QS;
eval_pqs_series_aux(0,N,args,NULL,&Q,&QS,&T);
return cl_I_to_LF(T,len) / scale_float(cl_I_to_LF(Q,len),QS);
}
}
// Bit complexity (if p(n), q(n), a(n), b(n) have length O(log(n))):
// O(log(N)^2*M(N)).
+
+} // namespace cln