00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 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_INTE_H 00024 #define O2SCL_GSL_INTE_H 00025 00026 #include <gsl/gsl_machine.h> 00027 00028 #ifndef DOXYGENP 00029 namespace o2scl { 00030 #endif 00031 00032 /** 00033 \brief GSL integration base 00034 00035 This base class does not perform any actual integration. 00036 00037 \todo Move the documentation below to a more sensible place 00038 00039 If the function integ() uses \c tolx and \c tolf 00040 to attempt to ensure that 00041 \f[ 00042 |\mathrm{result}-I| \leq \mathrm{Max}(\mathrm{tolx}, 00043 \mathrm{tolf}|I|) 00044 \f] 00045 and returns a value \c abserr to attempt to ensure that 00046 \f[ 00047 |\mathrm{result}-I| \leq \mathrm{abserr} \leq 00048 \mathrm{Max}(\mathrm{tolx},\mathrm{tolf}|I|) 00049 \f] 00050 where \c I is the integral to be evaluated. Even when 00051 integ() returns success, these inequalities will fail for 00052 some functions. 00053 */ 00054 class gsl_inte { 00055 00056 public: 00057 00058 gsl_inte() { 00059 } 00060 00061 protected: 00062 00063 /// Desc 00064 double rescale_error(double err, const double result_abs, 00065 const double result_asc) { 00066 err = fabs(err); 00067 00068 if (result_asc != 0 && err != 0) { 00069 00070 double scale = pow((200 * err / result_asc), 1.5); 00071 00072 if (scale < 1) { 00073 err = result_asc * scale; 00074 } else { 00075 err = result_asc; 00076 } 00077 } 00078 00079 if (result_abs > GSL_DBL_MIN / (50 * GSL_DBL_EPSILON)) { 00080 00081 double min_err = 50 * GSL_DBL_EPSILON * result_abs; 00082 00083 if (min_err > err) { 00084 err = min_err; 00085 } 00086 } 00087 00088 return err; 00089 } 00090 00091 }; 00092 00093 00094 #ifndef DOXYGENP 00095 } 00096 #endif 00097 00098 #endif