Unfit  3.1.1
Data fitting and optimization software
CardiacAlphaN.hpp
1 // Unfit: Data fitting and optimization software
2 //
3 // Copyright (C) 2012- Dr Martin Buist & Dr Alberto Corrias
4 // Contacts: martin.buist _at_ nus.edu.sg; alberto _at_ nus.edu.sg
5 //
6 // See the 'Contributors' file for a list of those who have contributed
7 // to this work.
8 //
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 //
22 #ifndef UNFIT_EXAMPLES_CARDIACALPHAN_HPP_
23 #define UNFIT_EXAMPLES_CARDIACALPHAN_HPP_
24 
25 #include <cmath>
26 #include <vector>
27 #include "GenericCostFunction.hpp"
28 
29 namespace Unfit
30 {
31 namespace Examples
32 {
47 {
48  public:
61  CardiacAlphaN(const std::vector<double> &vm,
62  const std::vector<double> &alpha_n)
63  : vm_ {vm},
64  alpha_n_ {alpha_n}
65  {}
66 
80  std::vector<double> operator()(const std::vector<double> &param)
81  {
82  auto residuals = alpha_n_;
83  for (unsigned i = 0; i < residuals.size(); ++i) {
84  residuals[i] -= param[0] / (1.0 + exp(param[1]*vm_[i] + param[2]));
85  }
86  return residuals;
87  }
88  private:
90  const std::vector<double> vm_;
92  const std::vector<double> alpha_n_;
93 };
94 
95 } // namespace Examples
96 } // namespace Unfit
97 
98 #endif
std::vector< double > operator()(const std::vector< double > &param)
Definition: CardiacAlphaN.hpp:80
const std::vector< double > alpha_n_
Definition: CardiacAlphaN.hpp:92
Definition: Bounds.hpp:27
Definition: GenericCostFunction.hpp:36
Fit the voltage dependence of a cardiac ion channel rate constant.
Definition: CardiacAlphaN.hpp:46
CardiacAlphaN(const std::vector< double > &vm, const std::vector< double > &alpha_n)
Definition: CardiacAlphaN.hpp:61
const std::vector< double > vm_
Definition: CardiacAlphaN.hpp:90