-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRateLookup.h
78 lines (67 loc) · 2.25 KB
/
RateLookup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**********************************************************************
** This program is part of 'MOOSE', the
** Messaging Object Oriented Simulation Environment.
** copyright (C) 2003-2007 Upinder S. Bhalla, Niraj Dudani and NCBS
** It is made available under the terms of the
** GNU Lesser General Public License version 2.1
** See the file COPYING.LIB for the full notice.
**********************************************************************/
#ifndef _RATE_LOOKUP_H
#define _RATE_LOOKUP_H
struct LookupRow
{
double* row; ///< Pointer to the first column on a row
double fraction; ///< Fraction of V or Ca over and above the division
///< boundary for interpolation.
};
struct LookupColumn
{
LookupColumn() { ; }
unsigned int column;
//~ bool interpolate;
};
class LookupTable
{
public:
LookupTable() { ; }
LookupTable(
double min, ///< min of range
double max, ///< max of range
unsigned int nDivs, ///< number of divisions (~ no. of rows)
unsigned int nSpecies ); ///< number of species (no. of columns / 2)
/// Adds the columns for a given species. Columns supplied are C1 and C2
void addColumns(
int species,
const vector< double >& C1,
const vector< double >& C2 );
//~ const vector< double >& C2,
//~ bool interpolate );
void column(
unsigned int species,
LookupColumn& column );
/**
* Returns the row corresponding to x in the "row" parameter.
* i.e., returns the leftover fraction and the row's start address.
*/
void row(
double x,
LookupRow& row );
/// Actually performs the lookup and the linear interpolation
void lookup(
const LookupColumn& column,
const LookupRow& row,
double& C1,
double& C2 );
private:
//~ vector< bool > interpolate_;
vector< double > table_; ///< Flattened table
double min_; ///< min of the voltage / caConc range
double max_; ///< max of the voltage / caConc range
unsigned int nPts_; ///< Number of rows in the table.
///< Equal to nDivs + 2, so that
///< interpol. is safe at either end.
double dx_; ///< This is the smallest difference:
///< (max - min) / nDivs
unsigned int nColumns_; ///< (# columns) = 2 * (# species)
};
#endif // _RATE_LOOKUP_H