QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Friends | List of all members
TridiagonalOperator Class Reference

Base implementation for tridiagonal operator. More...

#include <tridiagonaloperator.hpp>

+ Inheritance diagram for TridiagonalOperator:
+ Collaboration diagram for TridiagonalOperator:

Classes

class  TimeSetter
 encapsulation of time-setting logic More...
 

Public Types

typedef Array array_type
 

Public Member Functions

 TridiagonalOperator (Size size=0)
 
 TridiagonalOperator (const Array &low, const Array &mid, const Array &high)
 
 TridiagonalOperator (const TridiagonalOperator &)=default
 
 TridiagonalOperator (TridiagonalOperator &&) noexcept
 
TridiagonalOperatoroperator= (const TridiagonalOperator &)
 
TridiagonalOperatoroperator= (TridiagonalOperator &&) noexcept
 
 ~TridiagonalOperator ()=default
 
Inspectors
Size size () const
 
bool isTimeDependent () const
 
const ArraylowerDiagonal () const
 
const Arraydiagonal () const
 
const ArrayupperDiagonal () const
 
Modifiers
void setFirstRow (Real, Real)
 
void setMidRow (Size, Real, Real, Real)
 
void setMidRows (Real, Real, Real)
 
void setLastRow (Real, Real)
 
void setTime (Time t)
 

Friends

TridiagonalOperator operator+ (const TridiagonalOperator &)
 
TridiagonalOperator operator- (const TridiagonalOperator &)
 
TridiagonalOperator operator+ (const TridiagonalOperator &, const TridiagonalOperator &)
 
TridiagonalOperator operator- (const TridiagonalOperator &, const TridiagonalOperator &)
 
TridiagonalOperator operator* (Real, const TridiagonalOperator &)
 
TridiagonalOperator operator* (const TridiagonalOperator &, Real)
 
TridiagonalOperator operator/ (const TridiagonalOperator &, Real)
 

Utilities

Size n_
 
Array diagonal_
 
Array lowerDiagonal_
 
Array upperDiagonal_
 
Array temp_
 
ext::shared_ptr< TimeSettertimeSetter_
 
void swap (TridiagonalOperator &) noexcept
 

Operator interface

Array applyTo (const Array &v) const
 apply operator to a given array More...
 
Array solveFor (const Array &rhs) const
 solve linear system for a given right-hand side More...
 
void solveFor (const Array &rhs, Array &result) const
 
Array SOR (const Array &rhs, Real tol) const
 solve linear system with SOR approach More...
 
static TridiagonalOperator identity (Size size)
 identity instance More...
 

Detailed Description

Base implementation for tridiagonal operator.

Warning:
to use real time-dependant algebra, you must overload the corresponding operators in the inheriting time-dependent class.

Definition at line 42 of file tridiagonaloperator.hpp.

Member Typedef Documentation

◆ array_type

typedef Array array_type

Definition at line 58 of file tridiagonaloperator.hpp.

Constructor & Destructor Documentation

◆ TridiagonalOperator() [1/4]

TridiagonalOperator ( Size  size = 0)
explicit

Definition at line 25 of file tridiagonaloperator.cpp.

+ Here is the call graph for this function:

◆ TridiagonalOperator() [2/4]

TridiagonalOperator ( const Array low,
const Array mid,
const Array high 
)

Definition at line 44 of file tridiagonaloperator.cpp.

+ Here is the call graph for this function:

◆ TridiagonalOperator() [3/4]

◆ TridiagonalOperator() [4/4]

Definition at line 127 of file tridiagonaloperator.hpp.

+ Here is the call graph for this function:

◆ ~TridiagonalOperator()

~TridiagonalOperator ( )
default

Member Function Documentation

◆ operator=() [1/2]

TridiagonalOperator & operator= ( const TridiagonalOperator from)

Definition at line 131 of file tridiagonaloperator.hpp.

+ Here is the call graph for this function:

◆ operator=() [2/2]

TridiagonalOperator & operator= ( TridiagonalOperator &&  from)
noexcept

Definition at line 139 of file tridiagonaloperator.hpp.

+ Here is the call graph for this function:

◆ applyTo()

Array applyTo ( const Array v) const

apply operator to a given array

Definition at line 57 of file tridiagonaloperator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ solveFor() [1/2]

Array solveFor ( const Array rhs) const

solve linear system for a given right-hand side

Definition at line 79 of file tridiagonaloperator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ solveFor() [2/2]

void solveFor ( const Array rhs,
Array result 
) const

solve linear system for a given right-hand side without result Array allocation. The rhs and result parameters can be the same Array, in which case rhs will be changed

Definition at line 85 of file tridiagonaloperator.cpp.

+ Here is the call graph for this function:

◆ SOR()

Array SOR ( const Array rhs,
Real  tol 
) const

solve linear system with SOR approach

Definition at line 111 of file tridiagonaloperator.cpp.

+ Here is the call graph for this function:

◆ identity()

TridiagonalOperator identity ( Size  size)
static

identity instance

Definition at line 156 of file tridiagonaloperator.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

Size size ( ) const

Definition at line 89 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ isTimeDependent()

bool isTimeDependent ( ) const

Definition at line 90 of file tridiagonaloperator.hpp.

◆ lowerDiagonal()

const Array & lowerDiagonal ( ) const

Definition at line 91 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ diagonal()

const Array & diagonal ( ) const

Definition at line 92 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ upperDiagonal()

const Array & upperDiagonal ( ) const

Definition at line 93 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ setFirstRow()

void setFirstRow ( Real  valB,
Real  valC 
)

Definition at line 144 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ setMidRow()

void setMidRow ( Size  i,
Real  valA,
Real  valB,
Real  valC 
)

Definition at line 150 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ setMidRows()

void setMidRows ( Real  valA,
Real  valB,
Real  valC 
)

Definition at line 161 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ setLastRow()

void setLastRow ( Real  valA,
Real  valB 
)

Definition at line 171 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ setTime()

void setTime ( Time  t)

Definition at line 177 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

◆ swap()

void swap ( TridiagonalOperator from)
noexcept

Definition at line 182 of file tridiagonaloperator.hpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator+ [1/2]

TridiagonalOperator operator+ ( const TridiagonalOperator D)
friend

Definition at line 194 of file tridiagonaloperator.hpp.

◆ operator- [1/2]

TridiagonalOperator operator- ( const TridiagonalOperator D)
friend

Definition at line 199 of file tridiagonaloperator.hpp.

◆ operator+ [2/2]

TridiagonalOperator operator+ ( const TridiagonalOperator D1,
const TridiagonalOperator D2 
)
friend

Definition at line 207 of file tridiagonaloperator.hpp.

◆ operator- [2/2]

TridiagonalOperator operator- ( const TridiagonalOperator D1,
const TridiagonalOperator D2 
)
friend

Definition at line 216 of file tridiagonaloperator.hpp.

◆ operator* [1/2]

TridiagonalOperator operator* ( Real  a,
const TridiagonalOperator D 
)
friend

Definition at line 225 of file tridiagonaloperator.hpp.

◆ operator* [2/2]

TridiagonalOperator operator* ( const TridiagonalOperator D,
Real  a 
)
friend

Definition at line 234 of file tridiagonaloperator.hpp.

◆ operator/

TridiagonalOperator operator/ ( const TridiagonalOperator D,
Real  a 
)
friend

Definition at line 243 of file tridiagonaloperator.hpp.

Member Data Documentation

◆ n_

Size n_
protected

Definition at line 115 of file tridiagonaloperator.hpp.

◆ diagonal_

Array diagonal_
protected

Definition at line 116 of file tridiagonaloperator.hpp.

◆ lowerDiagonal_

Array lowerDiagonal_
protected

Definition at line 116 of file tridiagonaloperator.hpp.

◆ upperDiagonal_

Array upperDiagonal_
protected

Definition at line 116 of file tridiagonaloperator.hpp.

◆ temp_

Array temp_
mutableprotected

Definition at line 117 of file tridiagonaloperator.hpp.

◆ timeSetter_

ext::shared_ptr<TimeSetter> timeSetter_
protected

Definition at line 118 of file tridiagonaloperator.hpp.