MinimizerVariableTransformation.cxx

Go to the documentation of this file.
00001 // @(#)root/mathmore:$Id: MinimizerVariableTransformation.cxx 29162 2009-06-23 10:55:30Z brun $
00002 // Author: L. Moneta 2009
00003 
00004 // Implementation file for all the MinimizerVariableTransormation's 
00005 // (implementations taken from minuit2 classes) 
00006 
00007 
00008 #include "Math/MinimizerVariableTransformation.h"
00009 #include <cmath>
00010 #include <limits>
00011 
00012 namespace ROOT { 
00013 
00014    namespace Math { 
00015 
00016 // implementations for the class SinVariableTransformation
00017 
00018 double SinVariableTransformation::Int2ext(double value, double lower, double upper) const {
00019    // transformation from  internal (unlimited) to external values (limited by lower/upper )
00020    return lower + 0.5*(upper - lower)*(std::sin(value) + 1.);
00021 }
00022 
00023 double SinVariableTransformation::Ext2int(double value, double lower, double upper) const {
00024    // transformation from external (limited by lower/upper )  to internal (unlimited) values given the lower/upper limits
00025    
00026    double piby2 = 2.*std::atan(1.);
00027    static const double eps = std::numeric_limits<double>::epsilon(); 
00028    double distnn = 8.*std::sqrt(eps);
00029    double vlimhi = piby2 - distnn;
00030    double vlimlo = -piby2 + distnn;
00031    
00032    double yy = 2.*(value - lower)/(upper - lower) - 1.;
00033    double yy2 = yy*yy;
00034    if(yy2 > (1. - 8 * eps) ) {
00035       if(yy < 0.) {
00036          // lower limit
00037          //       std::cout<<"SinVariableTransformation warning: is at its lower allowed limit. "<<value<<std::endl;
00038          return vlimlo;
00039       } else {
00040          // upper limit
00041          //       std::cout<<"SinVariableTransformation warning: is at its upper allowed limit."<<std::endl;
00042          return vlimhi;
00043       }
00044       
00045    } else {
00046          return std::asin(yy); 
00047    }
00048 }
00049 
00050 double SinVariableTransformation::DInt2Ext(double value, double lower, double upper) const {
00051    // return the derivative of the internal to external transformation (Int2Ext) : d Int2Ext / d Int 
00052    return 0.5*((upper - lower)*std::cos(value));
00053 }  
00054 
00055 // sqrt up 
00056 // implementations for the class SqrtUpVariableTransformation
00057 
00058 
00059    double SqrtLowVariableTransformation::Int2ext(double value, double lower, double) const {
00060    /// internal to external transformation 
00061    double val = lower - 1. + std::sqrt( value*value + 1.);
00062    return val; 
00063 }
00064 
00065 
00066 double SqrtLowVariableTransformation::Ext2int(double value, double lower, double ) const {
00067    // external to internal transformation
00068    double yy = value - lower + 1.; 
00069    double yy2 = yy*yy; 
00070    if (yy2 < 1. ) 
00071       return 0; 
00072    else 
00073       return std::sqrt( yy2 -1); 
00074 }
00075 
00076 double SqrtLowVariableTransformation::DInt2Ext(double value, double, double) const {
00077    // derivative of internal to external transofrmation   :  d (Int2Ext) / d Int  
00078    double val = value/( std::sqrt( value*value + 1.) );
00079    return val; 
00080 }
00081 
00082 // sqrt up 
00083 // implementations for the class SqrtUpVariableTransformation
00084 
00085 double SqrtUpVariableTransformation::Int2ext(double value, double upper, double) const {
00086    // internal to external transformation
00087    double val = upper + 1. - std::sqrt( value*value + 1.);
00088    return val; 
00089 }
00090 
00091 
00092 double SqrtUpVariableTransformation::Ext2int(double value, double upper, double ) const {
00093    // external to internal transformation  
00094    double yy = upper - value + 1.; 
00095    double arg = yy*yy - 1; 
00096    return ( arg < 0 ) ? 0 : std::sqrt(arg); 
00097 }
00098 
00099 
00100 double SqrtUpVariableTransformation::DInt2Ext(double value, double, double) const {
00101    // derivative of internal to external transofrmation :  d Ext / d Int   
00102    double val = - value/( std::sqrt( value*value + 1.) );
00103    return val; 
00104 }
00105 
00106 
00107    } // end namespace Math
00108 
00109 } // end namespace ROOT
00110 

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