1 #ifndef NPSTAT_LOCATIONSCALETRANSFORM1_HH_
2 #define NPSTAT_LOCATIONSCALETRANSFORM1_HH_
19 template<
class LocationFunctor,
class ScaleFunctor>
24 const ScaleFunctor& scale,
25 const double paramMin = -DBL_MAX,
26 const double paramMax = DBL_MAX)
42 inline double getParamMin()
const {
return paramMin_;}
43 inline double getParamMax()
const {
return paramMax_;}
44 inline const LocationFunctor& getLocationFcn()
const {
return loc_;}
45 inline const ScaleFunctor& getScaleFcn()
const {
return scale_;}
46 inline double getLocation()
const
47 {
if (changed_) recalculate();
return m_;}
48 inline double getScale()
const
49 {
if (changed_) recalculate();
return s_;}
53 if (changed_) recalculate();
54 if (dydx) *dydx = 1.0/s_;
58 inline double transformBack(
const double y)
const
60 if (changed_) recalculate();
68 inline virtual gs::ClassId
classId()
const {
return gs::ClassId(*
this);}
69 virtual bool write(std::ostream&)
const;
72 static const char* classname()
74 static const std::string myClassName(
75 gs::template_class_name<LocationFunctor,ScaleFunctor>(
76 "npstat::LocationScaleTransform1"));
77 return myClassName.c_str();
79 static inline unsigned version() {
return 1;}
80 static LocationScaleTransform1* read(
81 const gs::ClassId&
id, std::istream&);
88 return loc_ == r.loc_ && scale_ == r.scale_ && param_ == r.param_ &&
89 paramMin_ == r.paramMin_ && paramMax_ == r.paramMax_;
93 inline void recalculate()
const
95 const double s = scale_(param_);
96 if (s <= 0.0)
throw std::invalid_argument(
97 "In npstat::LocationScaleTransform1::recalculate:"
98 " obtained scale is not positive");
104 inline void setParameterChecked(
unsigned,
const double value)
106 if (value < paramMin_ || value > paramMax_)
107 throw std::invalid_argument(
108 "In npstat::LocationScaleTransform1::setParameterChecked:"
109 " parameter value out of range");
114 inline void setAllParametersChecked(
const double* p)
116 if (p[0] < paramMin_ || p[0] > paramMax_)
117 throw std::invalid_argument(
118 "In npstat::LocationScaleTransform1::setAllParametersChecked:"
119 " parameter value out of range");
124 inline double getParameterChecked(
unsigned)
const {
return param_;}
126 LocationFunctor loc_;
134 mutable bool changed_;
138 #include "npstat/stat/LocationScaleTransform1.icc"
Definition: AbsArrayProjector.hh:14