00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_GSL_SERIES_H 00024 #define O2SCL_GSL_SERIES_H 00025 00026 #include <iostream> 00027 #include <o2scl/collection.h> 00028 #include <gsl/gsl_sum.h> 00029 00030 #ifndef DOXYGENP 00031 namespace o2scl { 00032 #endif 00033 00034 /** 00035 \brief Series acceleration by Levin u-transform (GSL) 00036 00037 Given an array of terms in a sum, this attempts to evaluate the 00038 entire sum with an estimate of the error. 00039 00040 \future Convert to a more generic vector type (This actually 00041 doesn't require much more than making a templated version of 00042 the gsl_sum_levin_u_minmax functions which accept a different 00043 type for the \c array parameter). 00044 */ 00045 class gsl_series { 00046 00047 public: 00048 00049 /** \brief \c size is the number of terms in the series 00050 */ 00051 gsl_series(int size=1); 00052 00053 virtual ~gsl_series(); 00054 00055 /** \brief Return the accelerated sum of the series with 00056 a simple error estimate 00057 00058 The input vector \c x should be an array with \c size values 00059 from <tt>x[0]</tt> to <tt>x[size-1]</tt> where /c size is the 00060 value given to the constructor or given to the \ref set_size() 00061 function. 00062 */ 00063 double series_accel(double *x, double &err); 00064 00065 /** \brief Return the accelerated sum of the series with 00066 an accurate error estimate 00067 00068 The input vector \c x should be an array with \c size values 00069 from <tt>x[0]</tt> to <tt>x[size-1]</tt> where /c size is the 00070 value given to the constructor or given to the \ref set_size() 00071 function. 00072 */ 00073 double series_accel_err(double *x, double &err); 00074 00075 /** \brief Set the number of terms */ 00076 int set_size(int new_size); 00077 00078 #ifndef DOXYGENP 00079 00080 protected: 00081 00082 /// The GSL workspace 00083 gsl_sum_levin_u_workspace *w; 00084 00085 /// The GSL workspace 00086 gsl_sum_levin_utrunc_workspace *wt; 00087 00088 /// The workspace size 00089 int size; 00090 00091 #endif 00092 00093 }; 00094 00095 #ifndef DOXYGENP 00096 } 00097 #endif 00098 00099 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page