MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VectorTable Class Reference

#include <VectorTable.h>

+ Collaboration diagram for VectorTable:

Public Member Functions

unsigned int getDiv () const
 
double getInvDx () const
 
double getMax () const
 
double getMin () const
 
vector< double > getTable () const
 
double lookupByIndex (unsigned int) const
 
double lookupByValue (double) const
 
void setDiv (unsigned int)
 
void setMax (double)
 
void setMin (double)
 
void setTable (vector< double >)
 
bool tableIsEmpty () const
 
 VectorTable ()
 

Static Public Member Functions

static const CinfoinitCinfo ()
 

Private Attributes

double invDx_
 
vector< double > table_
 
unsigned int xDivs_
 
double xMax_
 
double xMin_
 

Friends

istream & operator>> (istream &, VectorTable &)
 

Detailed Description

Definition at line 21 of file VectorTable.h.

Constructor & Destructor Documentation

VectorTable::VectorTable ( )

Definition at line 102 of file VectorTable.cpp.

103  invDx_(-1), table_(0)
104 { ; }
#define INIT_XMAX
Definition: VectorTable.cpp:13
unsigned int xDivs_
Definition: VectorTable.h:50
#define INIT_XMIN
Definition: VectorTable.cpp:12
vector< double > table_
Definition: VectorTable.h:55
double xMin_
Definition: VectorTable.h:51
#define INIT_XDIV
Definition: VectorTable.cpp:14
double xMax_
Definition: VectorTable.h:52
double invDx_
Definition: VectorTable.h:53

Member Function Documentation

unsigned int VectorTable::getDiv ( ) const

Definition at line 181 of file VectorTable.cpp.

References xDivs_.

Referenced by initCinfo(), and MarkovSolverBase::setLookupParams().

182 {
183  return xDivs_;
184 }
unsigned int xDivs_
Definition: VectorTable.h:50

+ Here is the caller graph for this function:

double VectorTable::getInvDx ( ) const

Definition at line 211 of file VectorTable.cpp.

References invDx_.

Referenced by initCinfo().

212 {
213  return invDx_;
214 }
double invDx_
Definition: VectorTable.h:53

+ Here is the caller graph for this function:

double VectorTable::getMax ( ) const

Definition at line 201 of file VectorTable.cpp.

References xMax_.

Referenced by initCinfo(), and MarkovSolverBase::setLookupParams().

202 {
203  return xMax_;
204 }
double xMax_
Definition: VectorTable.h:52

+ Here is the caller graph for this function:

double VectorTable::getMin ( ) const

Definition at line 191 of file VectorTable.cpp.

References xMin_.

Referenced by initCinfo(), and MarkovSolverBase::setLookupParams().

192 {
193  return xMin_;
194 }
double xMin_
Definition: VectorTable.h:51

+ Here is the caller graph for this function:

vector< double > VectorTable::getTable ( ) const

Definition at line 142 of file VectorTable.cpp.

References table_.

Referenced by initCinfo().

143 {
144  if ( table_.size() == 0 )
145  {
146  cerr << "VectorTable::getTable : Warning : Table is empty\n";
147  }
148 
149  return table_;
150 }
vector< double > table_
Definition: VectorTable.h:55

+ Here is the caller graph for this function:

const Cinfo * VectorTable::initCinfo ( )
static

Definition at line 18 of file VectorTable.cpp.

References getDiv(), getInvDx(), getMax(), getMin(), getTable(), Neutral::initCinfo(), lookupByIndex(), lookupByValue(), setDiv(), setMax(), setMin(), and setTable().

19 {
20  //Field information.
21  static ValueFinfo< VectorTable, unsigned int > xdivs("xdivs",
22  "Number of divisions.",
25  );
26 
27  static ValueFinfo< VectorTable, double > xmin("xmin",
28  "Minimum value in table.",
31  );
32 
33  static ValueFinfo< VectorTable, double > xmax("xmax",
34  "Maximum value in table.",
37  );
38 
39  static ReadOnlyValueFinfo< VectorTable, double > invdx("invdx",
40  "Maximum value in table.",
42  );
43 
44  static ValueFinfo< VectorTable, vector< double > > table("table",
45  "The lookup table.",
48  );
49 
51  lookupvalue(
52  "lookupvalue",
53  "Lookup function that performs interpolation to return a value.",
55  );
56 
58  lookupindex(
59  "lookupindex",
60  "Lookup function that returns value by index.",
62  );
63 
64  static Finfo* vectorTableFinfos[] =
65  {
66  &xdivs,
67  &xmin,
68  &xmax,
69  &invdx,
70  &table,
71  &lookupvalue,
72  &lookupindex
73  };
74 
75  static string doc[] =
76  {
77  "Name", "VectorTable",
78  "Author", "Vishaka Datta S, 2011, NCBS",
79  "Description", "This is a minimal 1D equivalent of the Interpol2D class. "
80  "Provides simple functions for getting and setting up the table, along "
81  "with a lookup function. This class is to be used while supplying lookup "
82  "tables to the MarkovChannel class, in cases where the transition rate "
83  "varies with either membrane voltage or ligand concentration."
84  };
85 
86  static Dinfo< VectorTable > dinfo;
87  static Cinfo VectorTableCinfo(
88  "VectorTable",
90  vectorTableFinfos,
91  sizeof( vectorTableFinfos )/sizeof( Finfo* ),
92  &dinfo,
93  doc,
94  sizeof( doc ) / sizeof( string )
95  );
96 
97  return &VectorTableCinfo;
98 }
double lookupByValue(double) const
double getInvDx() const
double getMin() const
vector< double > getTable() const
Definition: Dinfo.h:60
void setMin(double)
void setTable(vector< double >)
void setMax(double)
unsigned int getDiv() const
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
void setDiv(unsigned int)
Definition: Cinfo.h:18
double getMax() const
double lookupByIndex(unsigned int) const
Definition: Finfo.h:12

+ Here is the call graph for this function:

double VectorTable::lookupByIndex ( unsigned int  index) const

Definition at line 122 of file VectorTable.cpp.

References table_, and tableIsEmpty().

Referenced by initCinfo().

123 {
124  if ( tableIsEmpty() )
125  return 0;
126 
127  /* NOTE: Why commented out?
128  * index is unsigned int, can't be less than zero.
129  */
130 #if 0
131  //Applying similar wrapping as is done in lookupByValue.
132  if ( index < 0 )
133  index = 0;
134 #endif
135 
136  if ( index >= table_.size() )
137  index = table_.size() - 1;
138 
139  return table_[index];
140 }
bool tableIsEmpty() const
vector< double > table_
Definition: VectorTable.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double VectorTable::lookupByValue ( double  x) const

Definition at line 107 of file VectorTable.cpp.

References doubleEq(), invDx_, table_, xMax_, and xMin_.

Referenced by initCinfo().

108 {
109  if ( table_.size() == 1 )
110  return table_[0];
111 
112  if ( x < xMin_ || doubleEq( x, xMin_ ) )
113  return table_[0];
114  if ( x > xMax_ || doubleEq( x, xMax_ ) )
115  return table_.back();
116 
117  unsigned int index = static_cast< unsigned int>( ( x - xMin_ ) * invDx_ );
118  double frac = ( x - xMin_ - index / invDx_ ) * invDx_;
119  return table_[ index ] * ( 1 - frac ) + table_[ index + 1 ] * frac;
120 }
bool doubleEq(double x, double y)
Definition: doubleEq.cpp:16
vector< double > table_
Definition: VectorTable.h:55
double xMin_
Definition: VectorTable.h:51
double xMax_
Definition: VectorTable.h:52
double invDx_
Definition: VectorTable.h:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void VectorTable::setDiv ( unsigned int  xDivs)

Definition at line 186 of file VectorTable.cpp.

References xDivs_.

Referenced by initCinfo(), and MarkovRateTable::setConstantRate().

187 {
188  xDivs_ = xDivs;
189 }
unsigned int xDivs_
Definition: VectorTable.h:50

+ Here is the caller graph for this function:

void VectorTable::setMax ( double  xMax)

Definition at line 206 of file VectorTable.cpp.

References xMax_.

Referenced by initCinfo(), and MarkovRateTable::setConstantRate().

207 {
208  xMax_ = xMax;
209 }
double xMax_
Definition: VectorTable.h:52

+ Here is the caller graph for this function:

void VectorTable::setMin ( double  xMin)

Definition at line 196 of file VectorTable.cpp.

References xMin_.

Referenced by initCinfo(), and MarkovRateTable::setConstantRate().

197 {
198  xMin_ = xMin;
199 }
double xMin_
Definition: VectorTable.h:51

+ Here is the caller graph for this function:

void VectorTable::setTable ( vector< double >  table)

Definition at line 155 of file VectorTable.cpp.

References invDx_, table_, xDivs_, xMax_, and xMin_.

Referenced by initCinfo(), and MarkovRateTable::setConstantRate().

156 {
157  if ( table.size() > 1 && xMin_ == xMax_ )
158  {
159  cerr << "VectorTable::setTable : Error : xmin and xmax cannot be the same when there are more than "
160  "two entries in the table!\n";
161  return;
162  }
163 
164  if ( table.empty() )
165  {
166  cerr << "VectorTable::setTable : Error : Cannot set with empty table!\n";
167  return;
168  }
169 
170  table_ = table;
171  xDivs_ = table.size() - 1;
172 
173  //This is in case the lookup table has only one entry, in which case,
174  //the transition rate being considered is assumed to be constant.
175  if ( table.size() > 1 )
176  invDx_ = xDivs_ / ( xMax_ - xMin_ );
177  else
178  invDx_ = 0;
179 }
unsigned int xDivs_
Definition: VectorTable.h:50
vector< double > table_
Definition: VectorTable.h:55
double xMin_
Definition: VectorTable.h:51
double xMax_
Definition: VectorTable.h:52
double invDx_
Definition: VectorTable.h:53

+ Here is the caller graph for this function:

bool VectorTable::tableIsEmpty ( ) const

Definition at line 216 of file VectorTable.cpp.

References table_.

Referenced by lookupByIndex().

217 {
218  return table_.empty();
219 }
vector< double > table_
Definition: VectorTable.h:55

+ Here is the caller graph for this function:

Friends And Related Function Documentation

istream& operator>> ( istream &  ,
VectorTable  
)
friend

Member Data Documentation

double VectorTable::invDx_
private

Definition at line 53 of file VectorTable.h.

Referenced by getInvDx(), lookupByValue(), operator>>(), and setTable().

vector< double > VectorTable::table_
private

Definition at line 55 of file VectorTable.h.

Referenced by getTable(), lookupByIndex(), lookupByValue(), operator>>(), setTable(), and tableIsEmpty().

unsigned int VectorTable::xDivs_
private

Definition at line 50 of file VectorTable.h.

Referenced by getDiv(), operator>>(), setDiv(), and setTable().

double VectorTable::xMax_
private

Definition at line 52 of file VectorTable.h.

Referenced by getMax(), lookupByValue(), operator>>(), setMax(), and setTable().

double VectorTable::xMin_
private

Definition at line 51 of file VectorTable.h.

Referenced by getMin(), lookupByValue(), operator>>(), setMin(), and setTable().


The documentation for this class was generated from the following files: