-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New C++11 features may allow us to do away with much of the type heirarchy #577
Comments
This is clearly the way to go: #include <functional>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
class channel {
int p = 3;
int q = 1;
public:
string name = "unset";
double E = 50;
double g = 0;
double gbar = 0;
std::function<double(double)> m_inf;
channel(double gbar, double E, int p, int q) {
this->gbar = gbar;
this->E = E;
this->p = p;
this->q = q;
}
};
namespace prinz {
double NaV_m_inf(double V) {
return 1.0/(1.0+exp((V+25.5)/-5.29));
}
}
int main() {
channel NaV = channel(100,50,3,1);
NaV.m_inf = prinz::NaV_m_inf;
cout << "NaV.m_inf(30) = " << NaV.m_inf(-50) << endl;
} and we can use the |
This allows for a much richer type heirarchy:
Note the m_inf can have different type signatures for each, because |
unfortunately MATLAB doesn't support this:
|
Damn you, two language problem! |
but wait! there's a workaround: if one writes a setter method, everything is cool
and together with a wrapper method that calls |
p
,q
, and the activation functionswhat if, instead
conductance
was a concrete type, and had fields of type std::function<double(double)> form_inf
, etc? then the "prinz" channels could be specified by instantiatingconductance
objects, and filling out the functions as needed.The text was updated successfully, but these errors were encountered: