1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2003 Neil Firth
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 Adapted from the TNT project
20 http://math.nist.gov/tnt/download.html
21
22 This software was developed at the National Institute of Standards
23 and Technology (NIST) by employees of the Federal Government in the
24 course of their official duties. Pursuant to title 17 Section 105
25 of the United States Code this software is not subject to copyright
26 protection and is in the public domain. NIST assumes no responsibility
27 whatsoever for its use by other parties, and makes no guarantees,
28 expressed or implied, about its quality, reliability, or any other
29 characteristic.
30
31 We would appreciate acknowledgement if the software is incorporated in
32 redistributable libraries or applications.
33
34*/
35
36/*! \file svd.hpp
37 \brief singular value decomposition
38*/
39
40#ifndef quantlib_math_svd_h
41#define quantlib_math_svd_h
42
43#include <ql/math/matrix.hpp>
44
45namespace QuantLib {
46
47 //! Singular value decomposition
48 /*! Refer to Golub and Van Loan: Matrix computation,
49 The Johns Hopkins University Press
50
51 \test the correctness of the returned values is tested by
52 checking their properties.
53 */
54 class SVD {
55 public:
56 // constructor
57 explicit SVD(const Matrix&);
58 // results
59 const Matrix& U() const;
60 const Matrix& V() const;
61 const Array& singularValues() const;
62 Matrix S() const;
63 Real norm2() const;
64 Real cond() const;
65 Size rank() const;
66 // utilities
67 Array solveFor(const Array&) const;
68 private:
69 Matrix U_, V_;
70 Array s_;
71 Integer m_, n_;
72 bool transpose_;
73 };
74
75}
76
77
78#endif
79
80

source code of quantlib/ql/math/matrixutilities/svd.hpp