3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
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 */
31 # define __BEGIN_DECLS extern "C" {
32 # define __END_DECLS }
34 # define __BEGIN_DECLS /* empty */
35 # define __END_DECLS /* empty */
40 /* Workspace for Levin U Transform with error estimation,
42 * size = number of terms the workspace can handle
43 * sum_plain = simple sum of series
44 * q_num = backward diagonal of numerator; length = size
45 * q_den = backward diagonal of denominator; length = size
46 * dq_num = table of numerator derivatives; length = size**2
47 * dq_den = table of denominator derivatives; length = size**2
48 * dsum = derivative of sum wrt term i; length = size
54 size_t i; /* position in array */
55 size_t terms_used; /* number of calls */
63 gsl_sum_levin_u_workspace;
65 gsl_sum_levin_u_workspace *gsl_sum_levin_u_alloc (size_t n);
66 void gsl_sum_levin_u_free (gsl_sum_levin_u_workspace * w);
68 /* Basic Levin-u acceleration method.
70 * array = array of series elements
72 * sum_accel = result of summation acceleration
73 * err = estimated error
75 * See [Fessler et al., ACM TOMS 9, 346 (1983) and TOMS-602]
78 int gsl_sum_levin_u_accel (const double *array,
80 gsl_sum_levin_u_workspace * w,
81 double *sum_accel, double *abserr);
83 /* Basic Levin-u acceleration method with constraints on the terms
86 * array = array of series elements
88 * min_terms = minimum number of terms to sum
89 * max_terms = maximum number of terms to sum
90 * sum_accel = result of summation acceleration
91 * err = estimated error
93 * See [Fessler et al., ACM TOMS 9, 346 (1983) and TOMS-602]
96 int gsl_sum_levin_u_minmax (const double *array,
98 const size_t min_terms,
99 const size_t max_terms,
100 gsl_sum_levin_u_workspace * w,
101 double *sum_accel, double *abserr);
103 /* Basic Levin-u step w/o reference to the array of terms.
104 * We only need to specify the value of the current term
105 * to execute the step. See TOMS-745.
107 * sum = t0 + ... + t_{n-1} + term; term = t_{n}
109 * term = value of the series term to be added
110 * n = position of term in series (starting from 0)
111 * sum_accel = result of summation acceleration
112 * sum_plain = simple sum of series
116 gsl_sum_levin_u_step (const double term,
119 gsl_sum_levin_u_workspace * w,
122 /* The following functions perform the same calculation without
123 estimating the errors. They require O(N) storage instead of O(N^2).
124 This may be useful for summing many similar series where the size
125 of the error has already been estimated reliably and is not
126 expected to change. */
131 size_t i; /* position in array */
132 size_t terms_used; /* number of calls */
138 gsl_sum_levin_utrunc_workspace;
140 gsl_sum_levin_utrunc_workspace *gsl_sum_levin_utrunc_alloc (size_t n);
141 void gsl_sum_levin_utrunc_free (gsl_sum_levin_utrunc_workspace * w);
143 int gsl_sum_levin_utrunc_accel (const double *array,
145 gsl_sum_levin_utrunc_workspace * w,
146 double *sum_accel, double *abserr_trunc);
148 int gsl_sum_levin_utrunc_minmax (const double *array,
150 const size_t min_terms,
151 const size_t max_terms,
152 gsl_sum_levin_utrunc_workspace * w,
153 double *sum_accel, double *abserr_trunc);
155 int gsl_sum_levin_utrunc_step (const double term,
157 gsl_sum_levin_utrunc_workspace * w,
162 #endif /* __GSL_SUM_H__ */