1 /*
2 Copyright (C) 2013 Fredrik Johansson
3
4 This file is part of Arb.
5
6 Arb is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License (LGPL) as published
8 by the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version. See <http://www.gnu.org/licenses/>.
10 */
11
12 #include "acb_hypgeom.h"
13
main()14 int main()
15 {
16 slong iter;
17 flint_rand_t state;
18
19 flint_printf("chi_series....");
20 fflush(stdout);
21
22 flint_randinit(state);
23
24 for (iter = 0; iter < 200 * arb_test_multiplier(); iter++)
25 {
26 slong m, n1, n2, n3, bits1, bits2, bits3;
27 acb_poly_t S, A, B, C, T, U;
28
29 bits1 = 2 + n_randint(state, 200);
30 bits2 = 2 + n_randint(state, 200);
31 bits3 = 2 + n_randint(state, 200);
32
33 m = 1 + n_randint(state, 10);
34 n1 = 1 + n_randint(state, 10);
35 n2 = 1 + n_randint(state, 10);
36 n3 = FLINT_MIN(n1, n2);
37
38 acb_poly_init(S);
39 acb_poly_init(A);
40 acb_poly_init(B);
41 acb_poly_init(C);
42 acb_poly_init(T);
43 acb_poly_init(U);
44
45 acb_poly_randtest(S, state, m, bits1, 3);
46 acb_poly_randtest(A, state, m, bits1, 3);
47 acb_poly_randtest(B, state, m, bits1, 3);
48
49 acb_hypgeom_chi_series(A, S, n1, bits2);
50 acb_hypgeom_chi_series(B, S, n2, bits3);
51
52 acb_poly_set(C, A);
53 acb_poly_truncate(C, n3);
54 acb_poly_truncate(B, n3);
55
56 /* [Chi(h(x))]' h(x) = cosh(h(x)) h'(x) */
57 acb_poly_cosh_series(U, S, n3, bits2);
58 acb_poly_derivative(T, S, bits2);
59 acb_poly_mullow(U, U, T, FLINT_MAX(0, n3 - 1), bits2);
60
61 acb_poly_derivative(T, A, bits2);
62 acb_poly_mullow(T, T, S, FLINT_MAX(0, n3 - 1), bits2);
63
64 if (!acb_poly_overlaps(B, C) || !acb_poly_overlaps(T, U))
65 {
66 flint_printf("FAIL\n\n");
67 flint_printf("S = "); acb_poly_printd(S, 15); flint_printf("\n\n");
68 flint_printf("A = "); acb_poly_printd(A, 15); flint_printf("\n\n");
69 flint_printf("B = "); acb_poly_printd(B, 15); flint_printf("\n\n");
70 flint_printf("T = "); acb_poly_printd(T, 15); flint_printf("\n\n");
71 flint_printf("U = "); acb_poly_printd(U, 15); flint_printf("\n\n");
72 flint_abort();
73 }
74
75 acb_hypgeom_chi_series(S, S, n1, bits2);
76
77 if (!acb_poly_overlaps(A, S))
78 {
79 flint_printf("FAIL (aliasing)\n\n");
80 flint_abort();
81 }
82
83 acb_poly_clear(S);
84 acb_poly_clear(A);
85 acb_poly_clear(B);
86 acb_poly_clear(C);
87 acb_poly_clear(T);
88 acb_poly_clear(U);
89 }
90
91 flint_randclear(state);
92 flint_cleanup();
93 flint_printf("PASS\n");
94 return EXIT_SUCCESS;
95 }
96