![]() |
|
|||
File indexing completed on 2025-02-21 10:03:55
0001 /* sum/gsl_sum.h 0002 * 0003 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 3 of the License, or (at 0008 * your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, but 0011 * WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 /* Author: G. Jungman */ 0021 0022 0023 #ifndef __GSL_SUM_H__ 0024 #define __GSL_SUM_H__ 0025 0026 #include <stdlib.h> 0027 0028 #undef __BEGIN_DECLS 0029 #undef __END_DECLS 0030 #ifdef __cplusplus 0031 # define __BEGIN_DECLS extern "C" { 0032 # define __END_DECLS } 0033 #else 0034 # define __BEGIN_DECLS /* empty */ 0035 # define __END_DECLS /* empty */ 0036 #endif 0037 0038 __BEGIN_DECLS 0039 0040 /* Workspace for Levin U Transform with error estimation, 0041 * 0042 * size = number of terms the workspace can handle 0043 * sum_plain = simple sum of series 0044 * q_num = backward diagonal of numerator; length = size 0045 * q_den = backward diagonal of denominator; length = size 0046 * dq_num = table of numerator derivatives; length = size**2 0047 * dq_den = table of denominator derivatives; length = size**2 0048 * dsum = derivative of sum wrt term i; length = size 0049 */ 0050 0051 typedef struct 0052 { 0053 size_t size; 0054 size_t i; /* position in array */ 0055 size_t terms_used; /* number of calls */ 0056 double sum_plain; 0057 double *q_num; 0058 double *q_den; 0059 double *dq_num; 0060 double *dq_den; 0061 double *dsum; 0062 } 0063 gsl_sum_levin_u_workspace; 0064 0065 gsl_sum_levin_u_workspace *gsl_sum_levin_u_alloc (size_t n); 0066 void gsl_sum_levin_u_free (gsl_sum_levin_u_workspace * w); 0067 0068 /* Basic Levin-u acceleration method. 0069 * 0070 * array = array of series elements 0071 * n = size of array 0072 * sum_accel = result of summation acceleration 0073 * err = estimated error 0074 * 0075 * See [Fessler et al., ACM TOMS 9, 346 (1983) and TOMS-602] 0076 */ 0077 0078 int gsl_sum_levin_u_accel (const double *array, 0079 const size_t n, 0080 gsl_sum_levin_u_workspace * w, 0081 double *sum_accel, double *abserr); 0082 0083 /* Basic Levin-u acceleration method with constraints on the terms 0084 * used, 0085 * 0086 * array = array of series elements 0087 * n = size of array 0088 * min_terms = minimum number of terms to sum 0089 * max_terms = maximum number of terms to sum 0090 * sum_accel = result of summation acceleration 0091 * err = estimated error 0092 * 0093 * See [Fessler et al., ACM TOMS 9, 346 (1983) and TOMS-602] 0094 */ 0095 0096 int gsl_sum_levin_u_minmax (const double *array, 0097 const size_t n, 0098 const size_t min_terms, 0099 const size_t max_terms, 0100 gsl_sum_levin_u_workspace * w, 0101 double *sum_accel, double *abserr); 0102 0103 /* Basic Levin-u step w/o reference to the array of terms. 0104 * We only need to specify the value of the current term 0105 * to execute the step. See TOMS-745. 0106 * 0107 * sum = t0 + ... + t_{n-1} + term; term = t_{n} 0108 * 0109 * term = value of the series term to be added 0110 * n = position of term in series (starting from 0) 0111 * sum_accel = result of summation acceleration 0112 * sum_plain = simple sum of series 0113 */ 0114 0115 int 0116 gsl_sum_levin_u_step (const double term, 0117 const size_t n, 0118 const size_t nmax, 0119 gsl_sum_levin_u_workspace * w, 0120 double *sum_accel); 0121 0122 /* The following functions perform the same calculation without 0123 estimating the errors. They require O(N) storage instead of O(N^2). 0124 This may be useful for summing many similar series where the size 0125 of the error has already been estimated reliably and is not 0126 expected to change. */ 0127 0128 typedef struct 0129 { 0130 size_t size; 0131 size_t i; /* position in array */ 0132 size_t terms_used; /* number of calls */ 0133 double sum_plain; 0134 double *q_num; 0135 double *q_den; 0136 double *dsum; 0137 } 0138 gsl_sum_levin_utrunc_workspace; 0139 0140 gsl_sum_levin_utrunc_workspace *gsl_sum_levin_utrunc_alloc (size_t n); 0141 void gsl_sum_levin_utrunc_free (gsl_sum_levin_utrunc_workspace * w); 0142 0143 int gsl_sum_levin_utrunc_accel (const double *array, 0144 const size_t n, 0145 gsl_sum_levin_utrunc_workspace * w, 0146 double *sum_accel, double *abserr_trunc); 0147 0148 int gsl_sum_levin_utrunc_minmax (const double *array, 0149 const size_t n, 0150 const size_t min_terms, 0151 const size_t max_terms, 0152 gsl_sum_levin_utrunc_workspace * w, 0153 double *sum_accel, double *abserr_trunc); 0154 0155 int gsl_sum_levin_utrunc_step (const double term, 0156 const size_t n, 0157 gsl_sum_levin_utrunc_workspace * w, 0158 double *sum_accel); 0159 0160 __END_DECLS 0161 0162 #endif /* __GSL_SUM_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |