MultiNumGradFunction.cxx

Go to the documentation of this file.
00001 // @(#)root/mathmore:$Id: MultiNumGradFunction.cxx 29075 2009-06-17 21:06:45Z moneta $
00002 // Author: L. Moneta Wed Dec 20 14:36:31 2006
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
00007  *                                                                    *
00008  * This library is free software; you can redistribute it and/or      *
00009  * modify it under the terms of the GNU General Public License        *
00010  * as published by the Free Software Foundation; either version 2     *
00011  * of the License, or (at your option) any later version.             *
00012  *                                                                    *
00013  * This library 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 GNU   *
00016  * General Public License for more details.                           *
00017  *                                                                    *
00018  * You should have received a copy of the GNU General Public License  *
00019  * along with this library (see file COPYING); if not, write          *
00020  * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00021  * 330, Boston, MA 02111-1307 USA, or contact the author.             *
00022  *                                                                    *
00023  **********************************************************************/
00024 
00025 // implementation file for class MultiNumGradFunction
00026 
00027 #include "Math/MultiNumGradFunction.h"
00028 #include <limits>
00029 #include <cmath>
00030 #include <algorithm>    // needed for std::max on Solaris
00031 
00032 #ifndef ROOT_Math_Derivator
00033 #include "Math/Derivator.h"
00034 #endif
00035 
00036 
00037 namespace ROOT { 
00038 
00039    namespace Math { 
00040 
00041 
00042 double MultiNumGradFunction::fgEps = 0.001; 
00043 
00044 double MultiNumGradFunction::DoDerivative (const double * x, unsigned int icoord  ) const { 
00045       // calculate derivative using mathcore derivator class 
00046    // step size can be changes using SetDerivPrecision()
00047 
00048    static double kPrecision = std::sqrt ( std::numeric_limits<double>::epsilon() );
00049    double x0 = x[icoord];
00050    double step = std::max( fgEps* std::abs(x0), 8.0*kPrecision*(std::abs(x0) + kPrecision) );
00051    return ROOT::Math::Derivator::Eval(*fFunc, x, icoord, step); 
00052 }  
00053 
00054 void MultiNumGradFunction::SetDerivPrecision(double eps) { fgEps = eps; }
00055 
00056 double MultiNumGradFunction::GetDerivPrecision( ) { return fgEps; }
00057 
00058 
00059    } // end namespace Math
00060 
00061 } // end namespace ROOT

Generated on Tue Jul 5 14:34:57 2011 for ROOT_528-00b_version by  doxygen 1.5.1