QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
symmetricschurdecomposition.hpp
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
25#ifndef quantlib_math_jacobi_decomposition_h
26#define quantlib_math_jacobi_decomposition_h
27
28#include <ql/math/matrix.hpp>
29
30namespace QuantLib {
31
33
51 public:
54 const Array& eigenvalues() const { return diagonal_; }
55 const Matrix& eigenvectors() const { return eigenVectors_; }
56 private:
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
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
1-D array used in linear algebra.
Definition: array.hpp:52
Matrix used in linear algebra.
Definition: matrix.hpp:41
symmetric threshold Jacobi algorithm.
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.
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35