39 QL_FAIL(
"invalid size (" <<
size <<
") for tridiagonal operator "
40 "(must be null or >= 2)");
48 diagonal_(mid),
lowerDiagonal_(low), upperDiagonal_(high), temp_(n_) {
50 "low diagonal vector of size " << low.
size() <<
51 " instead of " <<
n_-1);
53 "high diagonal vector of size " << high.
size() <<
54 " instead of " <<
n_-1);
59 "uninitialized TridiagonalOperator");
61 "vector of the wrong size " <<
v.size() <<
62 " instead of " <<
n_);
71 for (
Size j=1; j<=
n_-2; j++)
86 Array& result)
const {
89 "uninitialized TridiagonalOperator");
91 "rhs vector of size " << rhs.
size() <<
92 " instead of " <<
n_);
96 "diagonal's first element (" << bet <<
97 ") cannot be close to zero");
98 result[0] = rhs[0]/bet;
99 for (
Size j=1; j<=
n_-1; ++j) {
106 for (
Size j=
n_-2; j>0; --j)
107 result[j] -=
temp_[j+1]*result[j+1];
108 result[0] -=
temp_[1]*result[1];
114 "uninitialized TridiagonalOperator");
116 "rhs vector of size " << rhs.
size() <<
117 " instead of " <<
n_);
126 for (
Size sorIteration=0; err>tol ; ++sorIteration) {
128 "tolerance (" << tol <<
") not reached in " <<
129 sorIteration <<
" iterations. " <<
130 "The error still is " << err);
132 temp = omega * (rhs[0] -
138 for (i=1; i<
n_-1 ; ++i) {
139 temp = omega *(rhs[i] -
147 temp = omega * (rhs[i] -
1-D array used in linear algebra.
const_iterator end() const
Size size() const
dimension of the array
const_iterator begin() const
Base implementation for tridiagonal operator.
Array solveFor(const Array &rhs) const
solve linear system for a given right-hand side
Array applyTo(const Array &v) const
apply operator to a given array
TridiagonalOperator(Size size=0)
Array SOR(const Array &rhs, Real tol) const
solve linear system with SOR approach
static TridiagonalOperator identity(Size size)
identity instance
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
std::size_t Size
size of a container
bool close(const Quantity &m1, const Quantity &m2, Size n)
ext::shared_ptr< BlackVolTermStructure > v