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