Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

math_util.hpp

Go to the documentation of this file.
00001 /*
00002  * ******** fete: From ENDF To ENDL *********
00003  * 
00004  * Copyright (c) 2006, The Regents of the University of California. 
00005  * All rights reserved.
00006  * 
00007  * Produced at the Lawrence Livermore National Laboratory. 
00008  * Written by David A. Brown, Gerry Hedstrom, Tony Hill
00009  * 
00010  * This file is part of fete v1.0  (UCRL-CODE-218718)
00011  * 
00012  * Please read the COPYING file for "Our Notice and GNU General 
00013  * Public License" in the root of this software distribution.  
00014  * 
00015  * This program is free software; you can redistribute it and/or modify 
00016  * it under the terms of the GNU General Public License (as published by 
00017  * the Free Software Foundation) version 2, dated June 1991. 
00018  * 
00019  * This program is distributed in the hope that it will be useful, 
00020  * but WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 
00022  * and conditions of the GNU General Public License for more details. 
00023  * 
00024  * You should have received a copy of the GNU General Public License along 
00025  * with this program; if not, write to the Free Software Foundation, Inc., 
00026  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
00027  * 
00028  * $Revision: 1806 $
00029  * $Date: 2006-03-27 15:37:19 -0800 (Mon, 27 Mar 2006) $
00030  * $Author: dbrown $
00031  * $Id: math_util.hpp 1806 2006-03-27 23:37:19Z dbrown $
00032  * 
00033  * ******** fete: From ENDF To ENDL *********
00034  */
00035 
00036 // header for my math routines
00037 #ifndef MATH_UTIL
00038 #define MATH_UTIL
00039 
00040 #include <iostream>
00041 #include <cmath>
00042 #include <cstdlib>
00043 #include <list>
00044 #include <vector>
00045 
00046 const double EPS = 1.0e-14; // machine precision
00047 
00048 using namespace std;
00049 
00050 // ----------- class Param -----------------
00051 //! The parameters of a probability function
00052 class Param:public vector< double >
00053 {
00054 public:
00055 
00056   Param( ):vector< double >(1,0.0){}
00057   Param( int dim, double val):vector< double >(dim,val){}
00058 
00059   //! Allocate space
00060   void get_space( int N ){resize(N);}
00061 
00062   //! Set parameters to zero
00063   void set_zero( );
00064 
00065   void print( );
00066 
00067   // operator *=, used in interpolation
00068   Param& operator*=( double alpha );
00069 
00070   // operator +=, used in interpolation
00071   Param& operator+=( Param& to_add );
00072 };
00073 
00074 // *************** basic interpolation routines *****************
00075 //! Interpolates between two points as lin-lin
00076 double Lin_Lin( double x_mid, double x_0, double y_0,
00077   double x_1, double y_1 );
00078 
00079 //! Interpolates between two points as lin-log
00080 double Lin_Log( double x_mid, double x_0, double y_0,
00081   double x_1, double y_1 );
00082 
00083 //! Interpolates between two points as log-lin
00084 double Log_Lin( double x_mid, double x_0, double y_0,
00085   double x_1, double y_1 );
00086 
00087 //! Interpolates between two points as log-log
00088 double Log_Log( double x_mid, double x_0, double y_0,
00089   double x_1, double y_1 );
00090 
00091 //!Determine maximum error in lin-lin interpolation of log-log data.
00092 double maxE_loglog( double xi, double alpha );
00093 
00094 // ******* translation of Slatec incomplete gamma function *****
00095 // int_0^x t^{a-1} exp{-t} dt / ( Gamma(a) * x^a )
00096 //! Incomplete gamma function
00097 double c_dgamit( double a, double x );
00098 
00099 // Gamma(a) = int_0^infinity t^{a-1} exp{-t} dt
00100 //! Gamma function
00101 double c_dgamma( double x );
00102 
00103 // ************ Bertulani exponential integral function ***********
00104 //! Exponential integral function
00105 double expint(int n, double x);
00106 
00107 // ************ for adaptive quadrature ******************
00108 //! Classes for Walter Gander's adaptive Simpson quadrature routine.
00109 //! See W. Gander and W. Gautschi, "Adaptive quadrature--revisited", BIT 40 (2000), 84-101.
00110 // --------------- quad_link ---------------------------
00111 //! Link for the list used by quadrature class quad_list
00112 struct quad_link
00113 {
00114 public:
00115   double a;   // left end point
00116   double b;   // right end point
00117   double fa;  // f(a)
00118   double fb;  // f(b)
00119   double fm;  // f( 0.5*(a + b) )
00120 };
00121 
00122 // --------------- quad_list ---------------------------
00123 //! The linked list used to hold the quadrature routine Simp_quad
00124 class quad_list : public list< quad_link >
00125 {
00126 private:
00127   double (*F_)( double x, Param& params );  // the function to integrate
00128   double A_;   // left end point
00129   double B_;   // right end point
00130   Param params_;  // the function paramters
00131   double is_;  // a rough approximation to the integral
00132   double tol_; // the tolerance
00133   double EPS_; // machine epsilon
00134   double sum_; // the value of the integral
00135   bool warning_set;
00136 
00137   //! Set up the first link and get a rough approximate integral
00138   void initialize( double A, double B, Param& params,
00139     double tol );
00140 
00141   //! To test one interval
00142   void test_int( quad_list::iterator link_ptr );
00143 
00144 public:
00145   quad_list( double ( *F )( double x, Param& params ) );
00146 
00147   ~quad_list( )
00148     {}
00149 
00150   //! Evaluate the integral
00151   double Simp_quad( double A, double B, Param& params,
00152     double tol );
00153 
00154 };
00155 
00156 #endif

Generated on Thu Sep 7 10:30:07 2006 for fete -- From ENDFB6 To ENDL by doxygen 1.3.4