QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
math
matrixutilities
symmetricschurdecomposition.hpp
Go to the documentation of this file.
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
Copyright (C) 2003 Ferdinando Ametrano
5
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
6
7
This file is part of QuantLib, a free-software/open-source library
8
for financial quantitative analysts and developers - http://quantlib.org/
9
10
QuantLib is free software: you can redistribute it and/or modify it
11
under the terms of the QuantLib license. You should have received a
12
copy of the license along with this program; if not, please email
13
<quantlib-dev@lists.sf.net>. The license is also available online at
14
<http://quantlib.org/license.shtml>.
15
16
This program is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
FOR A PARTICULAR PURPOSE. See the license for more details.
19
*/
20
21
/*! \file symmetricschurdecomposition.hpp
22
\brief Eigenvalues/eigenvectors of a real symmetric matrix
23
*/
24
25
#ifndef quantlib_math_jacobi_decomposition_h
26
#define quantlib_math_jacobi_decomposition_h
27
28
#include <
ql/math/matrix.hpp
>
29
30
namespace
QuantLib
{
31
32
//! symmetric threshold Jacobi algorithm.
33
/*! Given a real symmetric matrix S, the Schur decomposition
34
finds the eigenvalues and eigenvectors of S. If D is the
35
diagonal matrix formed by the eigenvalues and U the
36
unitarian matrix of the eigenvectors we can write the
37
Schur decomposition as
38
\f[ S = U \cdot D \cdot U^T \, ,\f]
39
where \f$ \cdot \f$ is the standard matrix product
40
and \f$ ^T \f$ is the transpose operator.
41
This class implements the Schur decomposition using the
42
symmetric threshold Jacobi algorithm. For details on the
43
different Jacobi transfomations see "Matrix computation,"
44
second edition, by Golub and Van Loan,
45
The Johns Hopkins University Press
46
47
\test the correctness of the returned values is tested by
48
checking their properties.
49
*/
50
class
SymmetricSchurDecomposition
{
51
public
:
52
/*! \pre s must be symmetric */
53
SymmetricSchurDecomposition
(
const
Matrix
&
s
);
54
const
Array
&
eigenvalues
()
const
{
return
diagonal_
; }
55
const
Matrix
&
eigenvectors
()
const
{
return
eigenVectors_
; }
56
private
:
57
Array
diagonal_
;
58
Matrix
eigenVectors_
;
59
void
jacobiRotate_
(
Matrix
& m,
Real
rot,
Real
dil,
60
Size
j1,
Size
k1,
Size
j2,
Size
k2)
const
;
61
};
62
63
64
// inline definitions
65
66
//! This routines implements the Jacobi, a.k.a. Givens, rotation
67
inline
void
SymmetricSchurDecomposition::jacobiRotate_
(
68
Matrix
&m,
Real
rot,
Real
dil,
Size
j1,
69
Size
k1,
Size
j2,
Size
k2)
const
{
70
Real
x1, x2;
71
x1 = m[j1][k1];
72
x2 = m[j2][k2];
73
m[j1][k1] = x1 - dil*(x2 + x1*rot);
74
m[j2][k2] = x2 + dil*(x1 - x2*rot);
75
}
76
77
}
78
79
80
#endif
81
82
QuantLib::Array
1-D array used in linear algebra.
Definition:
array.hpp:52
QuantLib::Matrix
Matrix used in linear algebra.
Definition:
matrix.hpp:41
QuantLib::SymmetricSchurDecomposition
symmetric threshold Jacobi algorithm.
Definition:
symmetricschurdecomposition.hpp:50
QuantLib::SymmetricSchurDecomposition::eigenVectors_
Matrix eigenVectors_
Definition:
symmetricschurdecomposition.hpp:58
QuantLib::SymmetricSchurDecomposition::jacobiRotate_
void jacobiRotate_(Matrix &m, Real rot, Real dil, Size j1, Size k1, Size j2, Size k2) const
This routines implements the Jacobi, a.k.a. Givens, rotation.
Definition:
symmetricschurdecomposition.hpp:67
QuantLib::SymmetricSchurDecomposition::eigenvectors
const Matrix & eigenvectors() const
Definition:
symmetricschurdecomposition.hpp:55
QuantLib::SymmetricSchurDecomposition::eigenvalues
const Array & eigenvalues() const
Definition:
symmetricschurdecomposition.hpp:54
QuantLib::SymmetricSchurDecomposition::diagonal_
Array diagonal_
Definition:
symmetricschurdecomposition.hpp:57
QuantLib::Real
QL_REAL Real
real number
Definition:
types.hpp:50
QuantLib::Size
std::size_t Size
size of a container
Definition:
types.hpp:58
matrix.hpp
matrix used in linear algebra.
QuantLib
Definition:
any.hpp:35
s
Real s
Definition:
perturbativebarrieroptionengine.cpp:1488
Generated by
Doxygen
1.9.5