#include <LinearMapper1d.h>
Public Member Functions | |
double | a () const |
double | b () const |
LinearMapper1d | inverse () const |
LinearMapper1d () | |
LinearMapper1d (const double x0, const double y0, const double x1, const double y1) | |
LinearMapper1d (const double ca, const double cb) | |
double | operator() (const double &x) const |
LinearMapper1d | operator* (const LinearMapper1d &r) const |
Private Attributes | |
double | a_ |
double | b_ |
Functor which performs linear mapping in 1-d
Definition at line 18 of file LinearMapper1d.h.
npstat::LinearMapper1d::LinearMapper1d | ( | ) | [inline] |
Default constructor builds an identity transformation
Definition at line 22 of file LinearMapper1d.h.
Referenced by inverse(), and operator*().
npstat::LinearMapper1d::LinearMapper1d | ( | const double | x0, |
const double | y0, | ||
const double | x1, | ||
const double | y1 | ||
) | [inline] |
Transform definition from two points. The point at x0 is mapped into y0, the point at x1 is mapped into y1. The linear transformation is thus fully defined.
Definition at line 29 of file LinearMapper1d.h.
{ const double dx = x1 - x0; if (!dx) throw npstat::NpstatInvalidArgument( "In npstat::LinearMapper1d constructor: " "invalid arguments (x0 == x1)"); a_ = (y1 - y0)/dx; b_ = ((y0 + y1) - a_*(x0 + x1))/2.0; }
npstat::LinearMapper1d::LinearMapper1d | ( | const double | ca, |
const double | cb | ||
) | [inline] |
Explicitly provide the transform coefficients as in y = ca*x + cb
Definition at line 41 of file LinearMapper1d.h.
double npstat::LinearMapper1d::a | ( | ) | const [inline] |
Get the linear coefficient of the transform
Definition at line 48 of file LinearMapper1d.h.
References a_.
{return a_;}
double npstat::LinearMapper1d::b | ( | ) | const [inline] |
Get the transform constant
Definition at line 51 of file LinearMapper1d.h.
References b_.
{return b_;}
LinearMapper1d npstat::LinearMapper1d::inverse | ( | ) | const [inline] |
Create the inverse transform
Definition at line 54 of file LinearMapper1d.h.
References a_, b_, and LinearMapper1d().
Referenced by npstat::densityScanHistoMap().
{ if (!a_) throw npstat::NpstatInvalidArgument( "In npstat::LinearMapper1d::inverse: " "mapping is not invertible"); return LinearMapper1d(1.0/a_, -b_/a_); }
double npstat::LinearMapper1d::operator() | ( | const double & | x | ) | const [inline] |
LinearMapper1d npstat::LinearMapper1d::operator* | ( | const LinearMapper1d & | r | ) | const [inline] |
Sequence of two transforms: the one on the right is applied first
Definition at line 63 of file LinearMapper1d.h.
References a_, b_, and LinearMapper1d().
double npstat::LinearMapper1d::a_ [private] |
Definition at line 69 of file LinearMapper1d.h.
Referenced by a(), inverse(), LinearMapper1d(), operator()(), and operator*().
double npstat::LinearMapper1d::b_ [private] |
Definition at line 70 of file LinearMapper1d.h.
Referenced by b(), inverse(), LinearMapper1d(), operator()(), and operator*().