1 // eval_rational_series().
7 #include "cl_LF_tran.h"
12 #include "cl_lfloat.h"
13 #include "cl_integer.h"
17 static void eval_pq_series_aux (uintL N1, uintL N2,
18 cl_pq_series_stream& args,
19 cl_I* P, cl_I* Q, cl_I* T)
25 var cl_pq_series_term v0 = args.next(); // [N1]
32 var cl_pq_series_term v0 = args.next(); // [N1]
33 var cl_pq_series_term v1 = args.next(); // [N1+1]
34 var cl_I p01 = v0.p * v1.p;
42 var cl_pq_series_term v0 = args.next(); // [N1]
43 var cl_pq_series_term v1 = args.next(); // [N1+1]
44 var cl_pq_series_term v2 = args.next(); // [N1+2]
45 var cl_I p01 = v0.p * v1.p;
46 var cl_I p012 = p01 * v2.p;
48 var cl_I q12 = v1.q * v2.q;
56 var cl_pq_series_term v0 = args.next(); // [N1]
57 var cl_pq_series_term v1 = args.next(); // [N1+1]
58 var cl_pq_series_term v2 = args.next(); // [N1+2]
59 var cl_pq_series_term v3 = args.next(); // [N1+3]
60 var cl_I p01 = v0.p * v1.p;
61 var cl_I p012 = p01 * v2.p;
62 var cl_I p0123 = p012 * v3.p;
63 if (P) { *P = p0123; }
64 var cl_I q23 = v2.q * v3.q;
65 var cl_I q123 = v1.q * q23;
74 var uintL Nm = (N1+N2)/2; // midpoint
77 eval_pq_series_aux(N1,Nm,args,&LP,&LQ,<);
78 // Compute right part.
80 eval_pq_series_aux(Nm,N2,args,(P?&RP:(cl_I*)0),&RQ,&RT);
81 // Put together partial results.
82 if (P) { *P = LP*RP; }
84 // S = LS + LP/LQ * RS, so T = RQ*LT + LP*RT.
91 const cl_LF eval_rational_series (uintL N, cl_pq_series_stream& args, uintC len)
94 return cl_I_to_LF(0,len);
96 eval_pq_series_aux(0,N,args,NULL,&Q,&T);
97 return cl_I_to_LF(T,len) / cl_I_to_LF(Q,len);