12 #include "../builtins/Interpol2D.h"
21 "Sends out instantaneous rate information of varying transition rates"
22 "at each time step.");
33 "Handles incoming message containing voltage information.",
37 static Finfo* channelShared[] =
43 "This message couples the rate table to the compartment. The rate table"
44 " needs updates on voltage in order to compute the rate table.",
45 channelShared,
sizeof( channelShared ) /
sizeof(
Finfo* )
52 "Handles process call",
56 "Handles reinit call",
59 static Finfo* processShared[] =
65 "This is a shared message to receive Process message from the"
66 "scheduler. The first entry is a MsgDest for the Process "
67 "operation. It has a single argument, ProcInfo, which "
68 "holds lots of information about current time, thread, dt and"
69 "so on. The second entry is a MsgDest for the Reinit "
70 "operation. It also uses ProcInfo.",
71 processShared,
sizeof( processShared ) /
sizeof(
Finfo* )
75 "Initialization of the class. Allocates memory for all the tables.",
79 "Handles incoming message containing ligand concentration.",
83 "Setting up of 1D lookup table for the (i,j)'th rate.",
90 "Setting up of 2D lookup table for the (i,j)'th rate.",
96 "Setting a constant value for the (i,j)'th rate. Internally, this is"
97 " stored as a 1-D rate with a lookup table containing 1 entry.",
106 "Ligand concentration.",
119 "Instantaneous rate matrix.",
128 "Dimension of the families of lookup tables. Is always equal to the number of states in the model.",
132 static Finfo* markovRateTableFinfos[] =
148 static string doc[] =
150 "Name",
"MarkovRateTable",
151 "Author",
"Vishaka Datta S, 2011, NCBS",
152 "Description",
"Rate Table for Markov channel calculations. "
158 markovRateTableFinfos,
159 sizeof(markovRateTableFinfos)/
sizeof(
Finfo *),
162 sizeof( doc ) /
sizeof(
string )
178 for (
unsigned int i = 0; i <
size_; ++i )
180 for (
unsigned int j = 0; j <
size_; ++j )
196 cerr <<
"MarkovRateTable::getVtChildTable : Error : No one parameter rate "
197 "table set for (" << i+1 <<
"," << j+1 <<
"). Returing NULL.\n";
204 unsigned int ligandFlag )
208 cerr <<
"MarkovRateTable::innerSetVtChildTable : Error : Table requested"
209 "is out of bounds!.\n";
216 cerr <<
"MarkovRateTable::innerSetVtChildTable : Error : "
217 "Rate (" << i+1 <<
"," << j+1 <<
")has already been set.\n";
223 cerr <<
"MarkovRateTable::innerSetVtChildTable : Error : Cannot "
224 "set diagonal rate (" << i+1 <<
"," << i+1 << endl;
242 cerr <<
"MarkovRateTable::getInt2dChildTable : Error : No two parameter"
243 " rate table set for (" << i+1 <<
"," << j+1 <<
"). Returning NULL.\n";
252 cerr <<
"MarkovRateTable::innerSetInt2dChildTable : Error : Table requested"
253 " is out of bounds\n";
259 cerr <<
"MarkovRateTable::innerSetInt2dChildTable : Error : Rate (" <<
260 i+1 <<
"," << j+1 <<
") has already been set!\n";
266 cerr <<
"MarkovRateTable::innerSetInt2dChildTable : Error : Cannot "
267 "set diagonal rate (" << i+1 <<
"," << i+1 << endl;
284 cerr <<
"MarkovRateTable::lookup1dValue : Lookup requested on non-existent"
285 "table at (" << i + 1 <<
"," << j + 1 <<
"). Returning 0.\n";
291 cerr <<
"MarkovRateTable::lookup1dValue : No 1D or constant rate set at "
292 "(" << i + 1 <<
"," << j + 1 <<
"). Returning 0.\n";
296 return vtTables_[i][j]->lookupByValue( x );
300 unsigned int xIndex )
304 cerr <<
"MarkovRateTable::lookup1dIndex : Lookup requested on non-"
305 "existent table at (" << i <<
"," << j <<
"). Returning 0.\n";
311 cerr <<
"MarkovRateTable::lookup1dIndex : No 1D or constant rate set at ("
312 << i <<
"," << j <<
"). Returning 0.\n";
316 return vtTables_[i][j]->lookupByIndex( xIndex );
324 cerr <<
"MarkovRateTable::lookup2dValue : Lookup requested on non-existent"
325 " table at (" << i + 1<<
"," << j+1 <<
"). Returning 0.\n";
331 cerr <<
"MarkovRateTable::lookup2dValue : No 2D rate set at (" << i+1 <<
","
332 << j+1 <<
"). Returning 0.\n";
340 unsigned int xIndex,
unsigned int yIndex )
344 cerr <<
"MarkovRateTable::lookup2dIndex : Lookup requested on non-existent"
345 " table at (" << i+1 <<
"," << j+1 <<
"). Returning 0.\n";
351 cerr <<
"MarkovRateTable::lookup2dIndex : No 2D rate set at (" << i+1 <<
","
352 << j+1 <<
"). Returning 0.\n";
356 vector< unsigned int > indices;
357 indices.push_back( xIndex );
358 indices.push_back( yIndex );
403 return (
vtTables_[i][j]->getDiv() == 0 );
414 return (
vtTables_[i][j]->getDiv() > 0 );
506 Q_[i][i] =
Q_[i][i] -
Q_[i][j] + temp;
521 Q_[i][i] =
Q_[i][i] -
Q_[i][j] + temp;
528 for (
unsigned int k = 0; k < n; ++k )
533 Q_[i][i] +=
Q_[i][j];
539 Q_[i][i] -=
Q_[i][j];
570 for (
unsigned int i = 0; i < rateTable.
size_; ++i )
572 for (
unsigned int j = 0; j < rateTable.
size_; ++j )
579 for (
unsigned int i = 0; i < rateTable.
size_; ++i )
581 for (
unsigned int j = 0; j < rateTable.
size_; ++j )
588 for (
unsigned int i = 0; i < rateTable.
size_; ++i )
590 for (
unsigned int j = 0; j < rateTable.
size_; ++j )
595 in >> rateTable.
size_;
602 return (
size_ > 0 );
621 cerr <<
"MarkovRateTable::reinit : MarkovRateTable class has not been"
641 Q_ = resize< double >(
Q_, size, 0 );
655 Id vecTabId,
unsigned int ligandFlag )
664 if ( ligandFlag > 0 )
693 vector< double > rateWrap;
694 rateWrap.push_back( rate );
vector< unsigned int > listOfConstantRates_
static SrcFinfo1< vector< vector< double > > > * instRatesOut()
istream & operator>>(istream &in, MarkovRateTable &rateTable)
vector< vector< Interpol2D * > > int2dTables_
vector< unsigned int > getListOf2dRates()
bool areIndicesOutOfBounds(unsigned int, unsigned int) const
void process(const Eref &, ProcPtr)
Interpol2D * getInt2dChildTable(unsigned int, unsigned int) const
void reinit(const Eref &, ProcPtr)
bool areAllRatesVoltageDep()
bool isRateConstant(unsigned int, unsigned int) const
vector< vector< double > > getQ() const
bool areAllRatesLigandDep()
void setVtChildTable(unsigned int, unsigned int, Id, unsigned int)
bool areAnyRatesLigandDep()
vector< unsigned int > listOf2dRates_
VectorTable * getVtChildTable(unsigned int, unsigned int) const
void setTable(vector< double >)
vector< unsigned int > getListOfConstantRates()
vector< unsigned int > listOfLigandRates_
static const Cinfo * initCinfo()
bool doubleEq(double x, double y)
vector< unsigned int > getListOf1dRates()
bool isRateLigandDep(unsigned int, unsigned int) const
bool areAnyRatesVoltageDep()
vector< unsigned int > getListOfVoltageRates()
bool isRate1d(unsigned int, unsigned int) const
bool isInitialized() const
vector< vector< VectorTable * > > vtTables_
bool isRate2d(unsigned int, unsigned int) const
bool isRateZero(unsigned int, unsigned int) const
static const Cinfo * MarkovRateTableCinfo
bool areAllRatesConstant()
vector< vector< unsigned int > > useLigandConc_
void innerSetVtChildTable(unsigned int, unsigned int, VectorTable, unsigned int)
double lookup2dValue(unsigned int, unsigned int, double, double)
void setConstantRate(unsigned int, unsigned int, double)
unsigned int getSize() const
vector< unsigned int > listOfVoltageRates_
static const Cinfo * initCinfo()
void setLigandConc(double)
vector< unsigned int > getListOfLigandRates()
void handleLigandConc(double)
void setInt2dChildTable(unsigned int, unsigned int, Id)
double lookup2dIndex(unsigned int, unsigned int, unsigned int, unsigned int)
vector< unsigned int > listOf1dRates_
double getLigandConc() const
void setDiv(unsigned int)
double lookup1dValue(unsigned int, unsigned int, double)
double lookup1dIndex(unsigned int, unsigned int, unsigned int)
void innerSetInt2dChildTable(unsigned int, unsigned int, Interpol2D)
vector< vector< double > > Q_