]> www.ginac.de Git - cln.git/blob - src/float/transcendental/cl_LF_tran.h
* Also filter out SCCS subdirs while recursing and searching for
[cln.git] / src / float / transcendental / cl_LF_tran.h
1 // cl_LF internals, transcendental functions
2
3 #ifndef _CL_LF_TRAN_H
4 #define _CL_LF_TRAN_H
5
6 #include "cln/integer.h"
7 #include "cln/lfloat.h"
8
9 namespace cln {
10
11 // Subroutine for evaluating
12 // sum(0 <= n < N, a(n)/b(n) * (p(0)...p(n))/(q(0)...q(n)))
13 // where all the entries are small integers (ideally polynomials in n).
14 // This is fast because it groups factors together before multiplying.
15 // Arguments:
16 //   Vectors p[0..N-1], q[0..N-1], a[0..N-1], b[0..N-1], N.
17 //   Some of the vectors (a,b,p,q) can be a NULL pointer, all of its entries
18 //   are then understood to be 1.
19 //   If given, a vector qs[0..N-1] which the evaluation routine may use to
20 //   split off q[n] into q[n]*2^qs[n]. qs may be NULL, in that case no shift
21 //   optimizations will be used. (They are worth it only if a significant
22 //   amount of multiplication work can be saved by shifts.)
23 // Result will be a cl_LF with len digits.
24
25 struct cl_rational_series {
26         // To be set explicitly.
27         const cl_I* pv;
28               cl_I* qv;
29         const cl_I* av;
30         const cl_I* bv;
31              uintL* qsv;
32 };
33 extern const cl_LF eval_rational_series (uintL N, const cl_rational_series& args, uintC len);
34
35 // In each the special cases below, none of (a,b,p,q) can be NULL. But qs can
36 // still be given or NULL.
37
38 struct cl_pqab_series {
39         const cl_I* pv;
40               cl_I* qv;
41         const cl_I* av;
42         const cl_I* bv;
43              uintL* qsv;
44 };
45 extern const cl_LF eval_rational_series (uintL N, const cl_pqab_series& args, uintC len);
46
47 struct cl_pqb_series {
48         const cl_I* pv;
49               cl_I* qv;
50         const cl_I* bv;
51              uintL* qsv;
52 };
53 extern const cl_LF eval_rational_series (uintL N, const cl_pqb_series& args, uintC len);
54
55 struct cl_pqa_series {
56         const cl_I* pv;
57               cl_I* qv;
58         const cl_I* av;
59              uintL* qsv;
60 };
61 extern const cl_LF eval_rational_series (uintL N, const cl_pqa_series& args, uintC len);
62
63 struct cl_pq_series {
64         const cl_I* pv;
65               cl_I* qv;
66              uintL* qsv;
67 };
68 extern const cl_LF eval_rational_series (uintL N, const cl_pq_series& args, uintC len);
69
70 struct cl_pab_series {
71         const cl_I* pv;
72         const cl_I* av;
73         const cl_I* bv;
74 };
75 extern const cl_LF eval_rational_series (uintL N, const cl_pab_series& args, uintC len);
76
77 struct cl_pb_series {
78         const cl_I* pv;
79         const cl_I* bv;
80 };
81 extern const cl_LF eval_rational_series (uintL N, const cl_pb_series& args, uintC len);
82
83 struct cl_pa_series {
84         const cl_I* pv;
85         const cl_I* av;
86 };
87 extern const cl_LF eval_rational_series (uintL N, const cl_pa_series& args, uintC len);
88
89 struct cl_p_series {
90         const cl_I* pv;
91 };
92 extern const cl_LF eval_rational_series (uintL N, const cl_p_series& args, uintC len);
93
94 struct cl_qab_series {
95               cl_I* qv;
96         const cl_I* av;
97         const cl_I* bv;
98              uintL* qsv;
99 };
100 extern const cl_LF eval_rational_series (uintL N, const cl_qab_series& args, uintC len);
101
102 struct cl_qb_series {
103               cl_I* qv;
104         const cl_I* bv;
105              uintL* qsv;
106 };
107 extern const cl_LF eval_rational_series (uintL N, const cl_qb_series& args, uintC len);
108
109 struct cl_qa_series {
110               cl_I* qv;
111         const cl_I* av;
112              uintL* qsv;
113 };
114 extern const cl_LF eval_rational_series (uintL N, const cl_qa_series& args, uintC len);
115
116 struct cl_q_series {
117               cl_I* qv;
118              uintL* qsv;
119 };
120 extern const cl_LF eval_rational_series (uintL N, const cl_q_series& args, uintC len);
121
122 struct cl_ab_series {
123         const cl_I* av;
124         const cl_I* bv;
125 };
126 extern const cl_LF eval_rational_series (uintL N, const cl_ab_series& args, uintC len);
127
128 struct cl_b_series {
129         const cl_I* bv;
130 };
131 extern const cl_LF eval_rational_series (uintL N, const cl_b_series& args, uintC len);
132
133 struct cl_a_series {
134         const cl_I* av;
135 };
136 extern const cl_LF eval_rational_series (uintL N, const cl_a_series& args, uintC len);
137
138 struct cl__series {
139 };
140 extern const cl_LF eval_rational_series (uintL N, const cl__series& args, uintC len);
141
142
143 // In this alternate implementation the series is not represented as a couple
144 // of arrays, but as a method returning each tuple (p(n),q(n),a(n),b(n))
145 // in turn. This is preferrable if the a(n) are big, in order to avoid too
146 // much memory usage at the same time.
147 // Some of the factors (a,b) may be omitted. They are then understood to be 1.
148 // The next function is called N times and is expected to return
149 // (p(n),q(n),a(n),b(n)) for n=0..N-1 in that order.
150
151 struct cl_pqab_series_term {
152         cl_I p;
153         cl_I q;
154         cl_I a;
155         cl_I b;
156 };
157 struct cl_pqab_series_stream {
158         cl_pqab_series_term (*nextfn)(cl_pqab_series_stream&);
159         cl_pqab_series_term next () { return nextfn(*this); }
160         // Constructor.
161         cl_pqab_series_stream (cl_pqab_series_term (*n)(cl_pqab_series_stream&)) : nextfn (n) {}
162 };
163 extern const cl_LF eval_rational_series (uintL N, cl_pqab_series_stream& args, uintC len);
164
165 struct cl_pqb_series_term {
166         cl_I p;
167         cl_I q;
168         cl_I b;
169 };
170 struct cl_pqb_series_stream {
171         cl_pqb_series_term (*nextfn)(cl_pqb_series_stream&);
172         cl_pqb_series_term next () { return nextfn(*this); }
173         // Constructor.
174         cl_pqb_series_stream (cl_pqb_series_term (*n)(cl_pqb_series_stream&)) : nextfn (n) {}
175 };
176 extern const cl_LF eval_rational_series (uintL N, cl_pqb_series_stream& args, uintC len);
177
178 struct cl_pqa_series_term {
179         cl_I p;
180         cl_I q;
181         cl_I a;
182 };
183 struct cl_pqa_series_stream {
184         cl_pqa_series_term (*nextfn)(cl_pqa_series_stream&);
185         cl_pqa_series_term next () { return nextfn(*this); }
186         // Constructor.
187         cl_pqa_series_stream (cl_pqa_series_term (*n)(cl_pqa_series_stream&)) : nextfn (n) {}
188 };
189 extern const cl_LF eval_rational_series (uintL N, cl_pqa_series_stream& args, uintC len);
190
191 struct cl_pq_series_term {
192         cl_I p;
193         cl_I q;
194 };
195 struct cl_pq_series_stream {
196         cl_pq_series_term (*nextfn)(cl_pq_series_stream&);
197         cl_pq_series_term next () { return nextfn(*this); }
198         // Constructor.
199         cl_pq_series_stream (cl_pq_series_term (*n)(cl_pq_series_stream&)) : nextfn (n) {}
200 };
201 extern const cl_LF eval_rational_series (uintL N, cl_pq_series_stream& args, uintC len);
202
203
204 // [Generalization.]
205 // Subroutine:
206 // Evaluates S = sum(N1 <= n < N2, (p(N1)...p(n))/(q(N1)...q(n)))
207 // and U = sum(N1 <= n < N2,
208 //             (c(N1)/d(N1)+...+c(n)/d(n))*(p(N1)...p(n))/(q(N1)...q(n)))
209 // and returns
210 //     P = p(N1)...p(N2-1),
211 //     Q = q(N1)...q(N2-1),
212 //     T = Q*S,
213 //     C/D = c(N1)/d(N1)+...+c(N2-1)/d(N2-1),
214 //     V = D*Q*U,
215 // all integers. On entry N1 < N2.
216 struct cl_pqcd_series_term {
217         cl_I p;
218         cl_I q;
219         cl_I c;
220         cl_I d;
221 };
222 struct cl_pqcd_series_result {
223         cl_I P;
224         cl_I Q;
225         cl_I T;
226         cl_I C;
227         cl_I D;
228         cl_I V;
229 };
230 extern void eval_pqcd_series_aux (uintL N, cl_pqcd_series_term* args, cl_pqcd_series_result& Z, cl_boolean rightmost = cl_true);
231 // Ditto, but returns U/S.
232 extern const cl_LF eval_pqcd_series (uintL N, cl_pqcd_series_term* args, uintC len);
233
234 // [Special case c(n)=1.]
235 // Subroutine:
236 // Evaluates S = sum(N1 <= n < N2, (p(N1)...p(n))/(q(N1)...q(n)))
237 // and U = sum(N1 <= n < N2, (1/d(N1)+...+1/d(n))*(p(N1)...p(n))/(q(N1)...q(n)))
238 // and returns
239 //     P = p(N1)...p(N2-1),
240 //     Q = q(N1)...q(N2-1),
241 //     T = Q*S,
242 //     C/D = 1/d(N1)+...+1/d(N2-1),
243 //     V = D*Q*U,
244 // all integers. On entry N1 < N2.
245 struct cl_pqd_series_term {
246         cl_I p;
247         cl_I q;
248         cl_I d;
249 };
250 struct cl_pqd_series_result {
251         cl_I P;
252         cl_I Q;
253         cl_I T;
254         cl_I C;
255         cl_I D;
256         cl_I V;
257 };
258 extern void eval_pqd_series_aux (uintL N, cl_pqd_series_term* args, cl_pqd_series_result& Z, cl_boolean rightmost = cl_true);
259 // Ditto, but returns U/S.
260 extern const cl_LF eval_pqd_series (uintL N, cl_pqd_series_term* args, uintC len);
261
262 }  // namespace cln
263
264 #endif /* _CL_LF_TRAN_H */