CMS 3D CMS Logo

Grid1D< T > Class Template Reference

#include <MagneticField/Interpolation/src/Grid1D.h>

List of all members.

Public Types

typedef T Scalar

Public Member Functions

int cells () const
Scalar closestNode (Scalar a) const
 Grid1D (Scalar lower, Scalar upper, int nodes)
 Grid1D ()
int index (Scalar a) const
 returns valid index, or -1 if the value is outside range +/- one cell.
Scalar lower () const
Scalar node (int i) const
int nodes () const
Scalar step () const
Scalar upper () const

Private Attributes

Scalar lower_
int nodes_
Scalar step_
Scalar upper_


Detailed Description

template<class T>
class Grid1D< T >

Definition at line 5 of file Grid1D.h.


Member Typedef Documentation

template<class T>
typedef T Grid1D< T >::Scalar

Definition at line 8 of file Grid1D.h.


Constructor & Destructor Documentation

template<class T>
Grid1D< T >::Grid1D (  )  [inline]

Definition at line 10 of file Grid1D.h.

00010 {}

template<class T>
Grid1D< T >::Grid1D ( Scalar  lower,
Scalar  upper,
int  nodes 
) [inline]

Definition at line 12 of file Grid1D.h.

References Grid1D< T >::step_.

00012                                                  : 
00013     lower_(lower), upper_(upper), nodes_(nodes) {
00014     step_ = (upper - lower) / (nodes-1);
00015   }


Member Function Documentation

template<class T>
int Grid1D< T >::cells (  )  const [inline]

Definition at line 22 of file Grid1D.h.

References Grid1D< T >::nodes().

Referenced by Grid1D< T >::index().

00022 {return nodes()-1;}

template<class T>
Scalar Grid1D< T >::closestNode ( Scalar  a  )  const [inline]

Definition at line 26 of file Grid1D.h.

References b, c, Grid1D< T >::lower(), max, min, Grid1D< T >::nodes(), Grid1D< T >::step(), and tmp.

00026                                       {
00027     Scalar b = (a-lower())/step();
00028     Scalar c = floor(b);
00029     Scalar tmp = (b-c < 0.5) ? std::max(c,0.) : std::min(c+1.,static_cast<Scalar>(nodes()-1));
00030     return tmp*step()+lower();
00031   }

template<class T>
int Grid1D< T >::index ( Scalar  a  )  const [inline]

returns valid index, or -1 if the value is outside range +/- one cell.

Definition at line 34 of file Grid1D.h.

References Grid1D< T >::cells(), Grid1D< T >::lower(), max, min, and Grid1D< T >::step().

00034                              {
00035     int ind = static_cast<int>((a-lower())/step());
00036     // FIXME: this causes an exception to be thrown later. Should be tested
00037     // more carefully before release
00038     //  if (ind < -1 || ind > cells()) {
00039     //     std::cout << "**** ind = " << ind << " cells: " << cells() << std::endl;
00040     //    return -1;
00041     //  }
00042     return std::max(0, std::min( cells()-1, ind));
00043   }

template<class T>
Scalar Grid1D< T >::lower (  )  const [inline]

Definition at line 19 of file Grid1D.h.

References Grid1D< T >::lower_.

Referenced by Grid1D< T >::closestNode(), Grid1D< T >::index(), Grid1D< T >::node(), and TrapezoidalCartesianMFGrid::TrapezoidalCartesianMFGrid().

00019 {return lower_;}

template<class T>
Scalar Grid1D< T >::node ( int  i  )  const [inline]

Definition at line 24 of file Grid1D.h.

References Grid1D< T >::lower(), and Grid1D< T >::step().

00024 { return i*step() + lower();}

template<class T>
int Grid1D< T >::nodes (  )  const [inline]

Definition at line 21 of file Grid1D.h.

References Grid1D< T >::nodes_.

Referenced by Grid1D< T >::cells(), and Grid1D< T >::closestNode().

00021 {return nodes_;}

template<class T>
Scalar Grid1D< T >::step (  )  const [inline]

Definition at line 18 of file Grid1D.h.

References Grid1D< T >::step_.

Referenced by Grid1D< T >::closestNode(), Grid1D< T >::index(), and Grid1D< T >::node().

00018 {return step_;}

template<class T>
Scalar Grid1D< T >::upper (  )  const [inline]

Definition at line 20 of file Grid1D.h.

References Grid1D< T >::upper_.

Referenced by TrapezoidalCartesianMFGrid::TrapezoidalCartesianMFGrid().

00020 {return upper_;}


Member Data Documentation

template<class T>
Scalar Grid1D< T >::lower_ [private]

Definition at line 48 of file Grid1D.h.

Referenced by Grid1D< T >::lower().

template<class T>
int Grid1D< T >::nodes_ [private]

Definition at line 50 of file Grid1D.h.

Referenced by Grid1D< T >::nodes().

template<class T>
Scalar Grid1D< T >::step_ [private]

Definition at line 47 of file Grid1D.h.

Referenced by Grid1D< T >::Grid1D(), and Grid1D< T >::step().

template<class T>
Scalar Grid1D< T >::upper_ [private]

Definition at line 49 of file Grid1D.h.

Referenced by Grid1D< T >::upper().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:23:15 2009 for CMSSW by  doxygen 1.5.4