MinimizerVariable.h

Go to the documentation of this file.
00001 // @(#)root/mathmore:$Id: MinimizerVariable.h 29068 2009-06-17 16:28:51Z moneta $
00002 // Author: L. Moneta 2009
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
00007  *                                                                    *
00008  *                                                                    *
00009  **********************************************************************/
00010 // Header file for class MinimizerVariable
00011 
00012 #ifndef ROOT_Math_MinimizerVariable
00013 #define ROOT_Math_MinimizerVariable
00014 
00015 #ifndef ROOT_Math_MinimizerVariableTransformation
00016 #include "MinimizerVariableTransformation.h"
00017 #endif
00018 
00019 #include <memory>
00020 
00021 namespace ROOT { 
00022 
00023    namespace Math { 
00024 
00025 
00026       /**
00027          Enumeration describing the status of the variable
00028          The enumeration are used in the minimizer classes to categorize the variables
00029       */
00030       enum EMinimVariableType { 
00031          kDefault,    // free variable (unlimited)
00032          kFix,        // fixed variable 
00033          kBounds,     //  variable has two bounds
00034          kLowBound,   // variable has a lower bound
00035          kUpBound     // variable has an upper bounds
00036       };
00037 
00038 /** 
00039    MinimizerVariable class to perform a transformations on the 
00040    variables to deal with fixed or limited variables
00041 
00042 
00043    @ingroup MultiMin
00044 */ 
00045 
00046 
00047 class MinimizerVariable { 
00048 
00049 public: 
00050 
00051    /** 
00052      Default Constructor for  an unlimited variable
00053    */ 
00054    MinimizerVariable () : 
00055       fFix(false), fLowBound(false), fUpBound(false), fBounds(false), 
00056       fTransform(0), fLower(1), fUpper(0)
00057    {}
00058 
00059    // constructor for fixed variable
00060    MinimizerVariable (double value) : 
00061       fFix(true), fLowBound(false), fUpBound(false), fBounds(false), 
00062       fTransform(0), fLower(value), fUpper(value) 
00063    {}
00064 
00065    // constructor for double bound variable
00066    MinimizerVariable (double lower, double upper, SinVariableTransformation * trafo) : 
00067       fFix(false), fLowBound(false), fUpBound(false), fBounds(true),      
00068       fTransform(trafo),
00069       fLower(lower), fUpper(upper)
00070    {   }
00071 
00072    // constructor for lower bound variable
00073    MinimizerVariable (double lower, SqrtLowVariableTransformation * trafo) : 
00074       fFix(false), fLowBound(true), fUpBound(false), fBounds(false), 
00075       fTransform(trafo), fLower(lower), fUpper(lower) 
00076    {}
00077 
00078    // constructor for upper bound variable
00079    MinimizerVariable (double upper, SqrtUpVariableTransformation * trafo) : 
00080       fFix(false), fLowBound(true), fUpBound(false), fBounds(false), 
00081       fTransform(trafo), fLower(upper), fUpper(upper) 
00082    {}
00083 
00084    // copy constructor 
00085    MinimizerVariable (const MinimizerVariable & rhs) : 
00086       fFix(rhs.fFix), fLowBound(rhs.fLowBound), fUpBound(rhs.fUpBound), fBounds(rhs.fBounds), 
00087       fLower(rhs.fLower), fUpper(rhs.fUpper)
00088    {
00089       // swap auto_ptr
00090       fTransform.reset( const_cast<MinimizerVariable &>( rhs).fTransform.release() ) ;      
00091    }
00092 
00093    // assignment 
00094    MinimizerVariable & operator= (const MinimizerVariable & rhs) {
00095       if (&rhs == this) return *this; 
00096       fFix = rhs.fFix;
00097       fLowBound = rhs.fLowBound;  
00098       fUpBound  = rhs.fUpBound; 
00099       fBounds   = rhs.fBounds;  
00100       fLower = rhs.fLower;  fUpper = rhs.fUpper;
00101 
00102       // swap auto_ptr
00103       fTransform.reset( const_cast<MinimizerVariable &>( rhs).fTransform.release() ) ;     
00104       return *this;
00105    }
00106    
00107 
00108    bool IsFixed() const { return fFix; }
00109    
00110    bool IsLimited() const { return fBounds || fLowBound || fUpBound; } 
00111 
00112    bool HasLowerBound() const { return fLowBound || fBounds; }
00113 
00114    bool HasUpperBound() const { return fUpBound || fBounds; }
00115 
00116    double LowerBound() const { return fLower; }
00117 
00118    double UpperBound() const { return fUpper; }
00119 
00120    double FixValue() const { return fLower; }
00121 
00122    // internal to external transformation 
00123    double InternalToExternal( double x) const { 
00124       return fTransform->Int2ext(x, fLower, fUpper); 
00125    }
00126 
00127    // derivative of the internal to external transformation ( d Int2Ext / d int )
00128    double DerivativeIntToExt ( double x) const { 
00129       return fTransform->DInt2Ext( x, fLower, fUpper); 
00130    }
00131 
00132    // etxernal to internal transformation
00133    double ExternalToInternal(double x) const { 
00134       return fTransform->Ext2int(x, fLower, fUpper);       
00135    }
00136 
00137 private: 
00138 
00139    bool fFix;         // fix variable
00140    bool fLowBound;    // has lower bound 
00141    bool fUpBound;     // has uppper bound param 
00142    bool fBounds;      // has double bound
00143    std::auto_ptr< MinimizerVariableTransformation> fTransform; // pointer to the minimizer transformation   
00144    double fLower;   // lower parameter limit
00145    double fUpper;   // upper parameter limit
00146  
00147 }; 
00148 
00149    } // end namespace Math
00150 
00151 } // end namespace ROOT
00152 
00153 
00154 #endif /* ROOT_Math_MinimizerVariable */
00155 
00156 

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