QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
math
matrixutilities
pseudosqrt.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, 2004 Ferdinando Ametrano
5
6
This file is part of QuantLib, a free-software/open-source library
7
for financial quantitative analysts and developers - http://quantlib.org/
8
9
QuantLib is free software: you can redistribute it and/or modify it
10
under the terms of the QuantLib license. You should have received a
11
copy of the license along with this program; if not, please email
12
<quantlib-dev@lists.sf.net>. The license is also available online at
13
<http://quantlib.org/license.shtml>.
14
15
This program is distributed in the hope that it will be useful, but WITHOUT
16
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
FOR A PARTICULAR PURPOSE. See the license for more details.
18
*/
19
20
/*! \file pseudosqrt.hpp
21
\brief pseudo square root of a real symmetric matrix
22
*/
23
24
#ifndef quantlib_pseudo_sqrt_hpp
25
#define quantlib_pseudo_sqrt_hpp
26
27
#include <
ql/math/matrix.hpp
>
28
29
namespace
QuantLib
{
30
31
//! algorithm used for matricial pseudo square root
32
struct
SalvagingAlgorithm
{
33
enum
Type
{
None
,
Spectral
,
Hypersphere
,
LowerDiagonal
,
Higham
};
34
};
35
36
//! Returns the pseudo square root of a real symmetric matrix
37
/*! Given a matrix \f$ M \f$, the result \f$ S \f$ is defined
38
as the matrix such that \f$ S S^T = M. \f$
39
If the matrix is not positive semi definite, it can
40
return an approximation of the pseudo square root
41
using a (user selected) salvaging algorithm.
42
43
For more information see: R. Rebonato and P. Jäckel, The most
44
general methodology to create a valid correlation matrix for
45
risk management and option pricing purposes, The Journal of
46
Risk, 2(2), Winter 1999/2000.
47
http://www.rebonato.com/correlationmatrix.pdf
48
49
Revised and extended in "Monte Carlo Methods in Finance",
50
by Peter Jäckel, Chapter 6.
51
52
\pre the given matrix must be symmetric.
53
54
\relates Matrix
55
56
\warning Higham algorithm only works for correlation matrices.
57
58
\test
59
- the correctness of the results is tested by reproducing
60
known good data.
61
- the correctness of the results is tested by checking
62
returned values against numerical calculations.
63
*/
64
Matrix
pseudoSqrt
(
const
Matrix&,
65
SalvagingAlgorithm::Type
=
SalvagingAlgorithm::None
);
66
67
//! Returns the rank-reduced pseudo square root of a real symmetric matrix
68
/*! The result matrix has rank<=maxRank. If maxRank>=size, then the
69
specified percentage of eigenvalues out of the eigenvalues' sum is
70
retained.
71
72
If the input matrix is not positive semi definite, it can return an
73
approximation of the pseudo square root using a (user selected)
74
salvaging algorithm.
75
76
\pre the given matrix must be symmetric.
77
78
\relates Matrix
79
*/
80
Matrix
rankReducedSqrt
(
const
Matrix&,
81
Size
maxRank,
82
Real
componentRetainedPercentage,
83
SalvagingAlgorithm::Type
);
84
}
85
86
87
#endif
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
QuantLib::pseudoSqrt
Matrix pseudoSqrt(const Matrix &matrix, SalvagingAlgorithm::Type sa)
Definition:
pseudosqrt.cpp:347
QuantLib::rankReducedSqrt
Matrix rankReducedSqrt(const Matrix &matrix, Size maxRank, Real componentRetainedPercentage, SalvagingAlgorithm::Type sa)
Definition:
pseudosqrt.cpp:427
QuantLib::SalvagingAlgorithm
algorithm used for matricial pseudo square root
Definition:
pseudosqrt.hpp:32
QuantLib::SalvagingAlgorithm::Type
Type
Definition:
pseudosqrt.hpp:33
QuantLib::SalvagingAlgorithm::Higham
@ Higham
Definition:
pseudosqrt.hpp:33
QuantLib::SalvagingAlgorithm::Hypersphere
@ Hypersphere
Definition:
pseudosqrt.hpp:33
QuantLib::SalvagingAlgorithm::None
@ None
Definition:
pseudosqrt.hpp:33
QuantLib::SalvagingAlgorithm::Spectral
@ Spectral
Definition:
pseudosqrt.hpp:33
QuantLib::SalvagingAlgorithm::LowerDiagonal
@ LowerDiagonal
Definition:
pseudosqrt.hpp:33
Generated by
Doxygen
1.9.5