3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 /* Author: G. Jungman */
25 #define CONCAT(a,b) a ## _ ## b
29 * f[n+1] + a[n] f[n] + b[n] f[n-1] = 0
31 * Trivial forward recurrence.
33 #define GEN_RECURSE_FORWARD_SIMPLE(func) \
34 int CONCAT(recurse_forward_simple, func) ( \
35 const int n_max, const int n_min, \
36 const double parameters[], \
37 const double f_n_min, \
38 const double f_n_min_p1, \
46 double f2 = f_n_min; \
47 double f1 = f_n_min_p1; \
49 for(n=n_min+2; n<=n_max; n++) { \
50 f0 = -REC_COEFF_A(n-1,parameters) * f1 - REC_COEFF_B(n-1, parameters) * f2; \
58 f[n_min + 1] = f_n_min_p1; \
59 for(n=n_min+2; n<=n_max; n++) { \
60 f[n] = -REC_COEFF_A(n-1,parameters) * f[n-1] - REC_COEFF_B(n-1, parameters) * f[n-2]; \
62 *f_n_max = f[n_max]; \
69 /* n_start >= n_max >= n_min
70 * f[n+1] + a[n] f[n] + b[n] f[n-1] = 0
72 * Generate the minimal solution of the above recursion relation,
73 * with the simplest form of the normalization condition, f[n_min] given.
74 * [Gautschi, SIAM Rev. 9, 24 (1967); (3.9) with s[n]=0]
76 #define GEN_RECURSE_BACKWARD_MINIMAL_SIMPLE(func) \
77 int CONCAT(recurse_backward_minimal_simple, func) ( \
79 const int n_max, const int n_min, \
80 const double parameters[], \
81 const double f_n_min, \
91 for(n=n_start; n > n_max; n--) { \
92 r_nm1 = -REC_COEFF_B(n, parameters) / (REC_COEFF_A(n, parameters) + r_n); \
97 f[n_max] = 10.*DBL_MIN; \
98 for(n=n_max; n > n_min; n--) { \
99 r_nm1 = -REC_COEFF_B(n, parameters) / (REC_COEFF_A(n, parameters) + r_n); \
100 f[n-1] = f[n] / r_nm1; \
103 ratio = f_n_min / f[n_min]; \
104 for(n=n_min; n<=n_max; n++) { \
110 double f_n = 10.*DBL_MIN; \
112 for(n=n_max; n > n_min; n--) { \
113 r_nm1 = -REC_COEFF_B(n, parameters) / (REC_COEFF_A(n, parameters) + r_n); \
114 f_nm1 = f_n / r_nm1; \
117 ratio = f_n_min / f_nm1; \
121 return GSL_SUCCESS; \
125 #endif /* !_RECURSE_H_ */