10 std::vector<double>& b, std::vector<double>& c,
11 std::vector<double>& f) {
12 std::size_t n = a.size() - 1;
14 std::vector<double> alpha;
17 std::vector<double> beta;
20 alpha[2] = b[1] / c[1];
21 beta[2] = f[1] / c[1];
23 for (std::size_t j = 2; j <= n - 1; j++) {
24 alpha[j + 1] = b[j] / (c[j] - a[j] * alpha[j]);
25 beta[j + 1] = (f[j] + a[j] * beta[j]) / (c[j] - a[j] * alpha[j]);
28 v[n] = (f[n] + a[n] * beta[n]) / (c[n] - a[n] * alpha[n]);
30 for (std::size_t j = n - 1; j >= 1; j--) {
31 v[j] = beta[j + 1] + alpha[j + 1] * v[j + 1];
Contains the definition of the Black-Sholes model.
void thomas_algorithm(std::vector< double > &v, std::vector< double > &a, std::vector< double > &b, std::vector< double > &c, std::vector< double > &f)
Implementation of Thomas algorithm for tridiagonal matrices.