#include <MagneticField/Interpolation/src/Grid1D.h>
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_ |
Definition at line 5 of file Grid1D.h.
Definition at line 22 of file Grid1D.h.
References Grid1D< T >::nodes().
Referenced by Grid1D< T >::index().
00022 {return nodes()-1;}
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 }
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 }
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_;}
Definition at line 21 of file Grid1D.h.
References Grid1D< T >::nodes_.
Referenced by Grid1D< T >::cells(), and Grid1D< T >::closestNode().
00021 {return nodes_;}
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_;}
Definition at line 20 of file Grid1D.h.
References Grid1D< T >::upper_.
Referenced by TrapezoidalCartesianMFGrid::TrapezoidalCartesianMFGrid().
00020 {return upper_;}
Definition at line 47 of file Grid1D.h.
Referenced by Grid1D< T >::Grid1D(), and Grid1D< T >::step().