Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
MinimizerVariableTransformation.cxx
Go to the documentation of this file.
1 // @(#)root/mathmore:$Id$
2 // Author: L. Moneta 2009
3 
4 // Implementation file for all the MinimizerVariableTransormation's
5 // (implementations taken from minuit2 classes)
6 
7 
9 #include <cmath>
10 #include <limits>
11 
12 namespace ROOT {
13 
14  namespace Math {
15 
16 // implementations for the class SinVariableTransformation
17 
18 double SinVariableTransformation::Int2ext(double value, double lower, double upper) const {
19  // transformation from internal (unlimited) to external values (limited by lower/upper )
20  return lower + 0.5*(upper - lower)*(std::sin(value) + 1.);
21 }
22 
23 double SinVariableTransformation::Ext2int(double value, double lower, double upper) const {
24  // transformation from external (limited by lower/upper ) to internal (unlimited) values given the lower/upper limits
25 
26  double piby2 = 2.*std::atan(1.);
27  static const double eps = std::numeric_limits<double>::epsilon();
28  double distnn = 8.*std::sqrt(eps);
29  double vlimhi = piby2 - distnn;
30  double vlimlo = -piby2 + distnn;
31 
32  double yy = 2.*(value - lower)/(upper - lower) - 1.;
33  double yy2 = yy*yy;
34  if(yy2 > (1. - 8 * eps) ) {
35  if(yy < 0.) {
36  // lower limit
37  // std::cout<<"SinVariableTransformation warning: is at its lower allowed limit. "<<value<<std::endl;
38  return vlimlo;
39  } else {
40  // upper limit
41  // std::cout<<"SinVariableTransformation warning: is at its upper allowed limit."<<std::endl;
42  return vlimhi;
43  }
44 
45  } else {
46  return std::asin(yy);
47  }
48 }
49 
50 double SinVariableTransformation::DInt2Ext(double value, double lower, double upper) const {
51  // return the derivative of the internal to external transformation (Int2Ext) : d Int2Ext / d Int
52  return 0.5*((upper - lower)*std::cos(value));
53 }
54 
55 // sqrt up
56 // implementations for the class SqrtUpVariableTransformation
57 
58 
59  double SqrtLowVariableTransformation::Int2ext(double value, double lower, double) const {
60  /// internal to external transformation
61  double val = lower - 1. + std::sqrt( value*value + 1.);
62  return val;
63 }
64 
65 
66 double SqrtLowVariableTransformation::Ext2int(double value, double lower, double ) const {
67  // external to internal transformation
68  double yy = value - lower + 1.;
69  double yy2 = yy*yy;
70  if (yy2 < 1. )
71  return 0;
72  else
73  return std::sqrt( yy2 -1);
74 }
75 
76 double SqrtLowVariableTransformation::DInt2Ext(double value, double, double) const {
77  // derivative of internal to external transofrmation : d (Int2Ext) / d Int
78  double val = value/( std::sqrt( value*value + 1.) );
79  return val;
80 }
81 
82 // sqrt up
83 // implementations for the class SqrtUpVariableTransformation
84 
85 double SqrtUpVariableTransformation::Int2ext(double value, double upper, double) const {
86  // internal to external transformation
87  double val = upper + 1. - std::sqrt( value*value + 1.);
88  return val;
89 }
90 
91 
92 double SqrtUpVariableTransformation::Ext2int(double value, double upper, double ) const {
93  // external to internal transformation
94  double yy = upper - value + 1.;
95  double arg = yy*yy - 1;
96  return ( arg < 0 ) ? 0 : std::sqrt(arg);
97 }
98 
99 
100 double SqrtUpVariableTransformation::DInt2Ext(double value, double, double) const {
101  // derivative of internal to external transofrmation : d Ext / d Int
102  double val = - value/( std::sqrt( value*value + 1.) );
103  return val;
104 }
105 
106 
107  } // end namespace Math
108 
109 } // end namespace ROOT
110