CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Attributes
npstat::LinearMapper1d Class Reference

#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_
 

Detailed Description

Functor which performs linear mapping in 1-d

Definition at line 18 of file LinearMapper1d.h.

Constructor & Destructor Documentation

◆ LinearMapper1d() [1/3]

npstat::LinearMapper1d::LinearMapper1d ( )
inline

Default constructor builds an identity transformation

Definition at line 21 of file LinearMapper1d.h.

Referenced by inverse(), and operator*().

21 : a_(1.0), b_(0.0) {}

◆ LinearMapper1d() [2/3]

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 28 of file LinearMapper1d.h.

References a_, b_, PVValHelper::dx, and testProducerWithPsetDescEmpty_cfi::y1.

28  {
29  const double dx = x1 - x0;
30  if (!dx)
32  "In npstat::LinearMapper1d constructor: "
33  "invalid arguments (x0 == x1)");
34  a_ = (y1 - y0) / dx;
35  b_ = ((y0 + y1) - a_ * (x0 + x1)) / 2.0;
36  }

◆ LinearMapper1d() [3/3]

npstat::LinearMapper1d::LinearMapper1d ( const double  ca,
const double  cb 
)
inline

Explicitly provide the transform coefficients as in y = ca*x + cb

Definition at line 39 of file LinearMapper1d.h.

39 : a_(ca), b_(cb) {}

Member Function Documentation

◆ a()

double npstat::LinearMapper1d::a ( ) const
inline

Get the linear coefficient of the transform

Definition at line 45 of file LinearMapper1d.h.

References a_.

45 { return a_; }

◆ b()

double npstat::LinearMapper1d::b ( ) const
inline

Get the transform constant

Definition at line 48 of file LinearMapper1d.h.

References b_.

48 { return b_; }

◆ inverse()

LinearMapper1d npstat::LinearMapper1d::inverse ( ) const
inline

Create the inverse transform

Definition at line 51 of file LinearMapper1d.h.

References a_, b_, and LinearMapper1d().

51  {
52  if (!a_)
54  "In npstat::LinearMapper1d::inverse: "
55  "mapping is not invertible");
56  return LinearMapper1d(1.0 / a_, -b_ / a_);
57  }

◆ operator()()

double npstat::LinearMapper1d::operator() ( const double &  x) const
inline

Perform the transformation

Definition at line 42 of file LinearMapper1d.h.

References a_, b_, and x.

42 { return a_ * x + b_; }
float x

◆ operator*()

LinearMapper1d npstat::LinearMapper1d::operator* ( const LinearMapper1d r) const
inline

Sequence of two transforms: the one on the right is applied first

Definition at line 60 of file LinearMapper1d.h.

References a_, b_, and LinearMapper1d().

Member Data Documentation

◆ a_

double npstat::LinearMapper1d::a_
private

Definition at line 63 of file LinearMapper1d.h.

Referenced by a(), inverse(), LinearMapper1d(), operator()(), and operator*().

◆ b_

double npstat::LinearMapper1d::b_
private

Definition at line 64 of file LinearMapper1d.h.

Referenced by b(), inverse(), LinearMapper1d(), operator()(), and operator*().