24#ifndef quantlib_laplace_interpolation
25#define quantlib_laplace_interpolation
27#include <ql/math/matrixutilities/bicgstab.hpp>
28#include <ql/math/matrixutilities/sparsematrix.hpp>
50 QL_REQUIRE(n > 1 && m > 1,
"matrix (" << m <<
"," << n
51 <<
") must at least be 2x2");
54 Array rhs(m * n, 0.0), guess(m * n, 0.0);
56 Size i1, i2, i3, i4, j1, j2, j3, j4;
59 for (
Size l = 0, i = 0; i < m; ++i) {
60 for (
Size j = 0; j < n; ++j) {
107 if (i > 0 && i < m - 1) {
108 if (j == 0 || j == n - 1) {
125 g(l, i * n + j) = 1.0;
128 g(l, i1 * n + j1) = -0.25;
129 g(l, i2 * n + j2) = -0.25;
130 g(l, i3 * n + j3) = -0.25;
131 g(l, i4 * n + j4) = -0.25;
133 g(l, i1 * n + j1) = -0.5;
134 g(l, i2 * n + j2) = -0.5;
140 guess[l] = guessTmp = A[i][j];
152 for (
Size i = 0; i < m; ++i) {
153 for (
Size j = 0; j < n; ++j) {
155 A[i][j] = s[i * n + j];
1-D array used in linear algebra.
BiCGStabResult solve(const Array &b, const Array &x0=Array()) const
template class providing a null value for a given type.
std::size_t Size
size of a container
Array prod(const SparseMatrix &A, const Array &x)
void laplaceInterpolation(M &A, Real relTol=1E-6)
boost::numeric::ublas::compressed_matrix< Real > SparseMatrix