1 | /*! |
---|
2 | * \file |
---|
3 | * \brief Definitions of Singular Value Decompositions |
---|
4 | * \author Tony Ottosson |
---|
5 | * |
---|
6 | * ------------------------------------------------------------------------- |
---|
7 | * |
---|
8 | * IT++ - C++ library of mathematical, signal processing, speech processing, |
---|
9 | * and communications classes and functions |
---|
10 | * |
---|
11 | * Copyright (C) 1995-2007 (see AUTHORS file for a list of contributors) |
---|
12 | * |
---|
13 | * This program is free software; you can redistribute it and/or modify |
---|
14 | * it under the terms of the GNU General Public License as published by |
---|
15 | * the Free Software Foundation; either version 2 of the License, or |
---|
16 | * (at your option) any later version. |
---|
17 | * |
---|
18 | * This program is distributed in the hope that it will be useful, |
---|
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | * GNU General Public License for more details. |
---|
22 | * |
---|
23 | * You should have received a copy of the GNU General Public License |
---|
24 | * along with this program; if not, write to the Free Software |
---|
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
26 | * |
---|
27 | * ------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | |
---|
30 | #ifndef SVD_H |
---|
31 | #define SVD_H |
---|
32 | |
---|
33 | #include <itpp/base/mat.h> |
---|
34 | |
---|
35 | |
---|
36 | namespace itpp { |
---|
37 | |
---|
38 | /*! |
---|
39 | * \ingroup matrixdecomp |
---|
40 | * \brief Get singular values \c s of a real matrix \c A using SVD |
---|
41 | * |
---|
42 | * This function calculates singular values \f$s\f$ from the SVD |
---|
43 | * decomposition of a real matrix \f$A\f$. The SVD algorithm computes the |
---|
44 | * decomposition of a real \f$m \times n\f$ matrix \f$\mathbf{A}\f$ so |
---|
45 | * that |
---|
46 | * \f[ |
---|
47 | * \mathrm{diag}(\mathbf{U}^T \mathbf{A} \mathbf{V}) = \mathbf{s} |
---|
48 | * = \sigma_1, \ldots, \sigma_p |
---|
49 | * \f] |
---|
50 | * where \f$\sigma_1 \geq \sigma_2 \geq \ldots \sigma_p \geq 0\f$ are the |
---|
51 | * singular values of \f$\mathbf{A}\f$. |
---|
52 | * Or put differently: |
---|
53 | * \f[ |
---|
54 | * \mathbf{A} = \mathbf{U} \mathbf{S} \mathbf{V}^T |
---|
55 | * \f] |
---|
56 | * where \f$ \mathrm{diag}(\mathbf{S}) = \mathbf{s} \f$ |
---|
57 | * |
---|
58 | * \note An external LAPACK library is required by this function. |
---|
59 | */ |
---|
60 | bool svd(const mat &A, vec &s); |
---|
61 | |
---|
62 | /*! |
---|
63 | * \ingroup matrixdecomp |
---|
64 | * \brief Get singular values \c s of a complex matrix \c A using SVD |
---|
65 | * |
---|
66 | * This function calculates singular values \f$s\f$ from the SVD |
---|
67 | * decomposition of a complex matrix \f$A\f$. The SVD algorithm computes |
---|
68 | * the decomposition of a complex \f$m \times n\f$ matrix \f$\mathbf{A}\f$ |
---|
69 | * so that |
---|
70 | * \f[ |
---|
71 | * \mathrm{diag}(\mathbf{U}^H \mathbf{A} \mathbf{V}) = \mathbf{s} |
---|
72 | * = \sigma_1, \ldots, \sigma_p |
---|
73 | * \f] |
---|
74 | * where \f$\sigma_1 \geq \sigma_2 \geq \ldots \sigma_p \geq 0\f$ |
---|
75 | * are the singular values of \f$\mathbf{A}\f$. |
---|
76 | * Or put differently: |
---|
77 | * \f[ |
---|
78 | * \mathbf{A} = \mathbf{U} \mathbf{S} \mathbf{V}^H |
---|
79 | * \f] |
---|
80 | * where \f$ \mathrm{diag}(\mathbf{S}) = \mathbf{s} \f$ |
---|
81 | * |
---|
82 | * \note An external LAPACK library is required by this function. |
---|
83 | */ |
---|
84 | bool svd(const cmat &A, vec &s); |
---|
85 | |
---|
86 | /*! |
---|
87 | * \ingroup matrixdecomp |
---|
88 | * \brief Return singular values of a real matrix \c A using SVD |
---|
89 | * |
---|
90 | * This function returns singular values from the SVD decomposition |
---|
91 | * of a real matrix \f$A\f$. The SVD algorithm computes the decomposition |
---|
92 | * of a real \f$m \times n\f$ matrix \f$\mathbf{A}\f$ so that |
---|
93 | * \f[ |
---|
94 | * \mathrm{diag}(\mathbf{U}^T \mathbf{A} \mathbf{V}) = \mathbf{s} |
---|
95 | * = \sigma_1, \ldots, \sigma_p |
---|
96 | * \f] |
---|
97 | * where \f$\sigma_1 \geq \sigma_2 \geq \ldots \sigma_p \geq 0\f$ are the |
---|
98 | * singular values of \f$\mathbf{A}\f$. |
---|
99 | * Or put differently: |
---|
100 | * \f[ |
---|
101 | * \mathbf{A} = \mathbf{U} \mathbf{S} \mathbf{V}^T |
---|
102 | * \f] |
---|
103 | * where \f$ \mathrm{diag}(\mathbf{S}) = \mathbf{s} \f$ |
---|
104 | * |
---|
105 | * \note An external LAPACK library is required by this function. |
---|
106 | */ |
---|
107 | vec svd(const mat &A); |
---|
108 | |
---|
109 | /*! |
---|
110 | * \ingroup matrixdecomp |
---|
111 | * \brief Return singular values of a complex matrix \c A using SVD |
---|
112 | * |
---|
113 | * This function returns singular values from the SVD |
---|
114 | * decomposition of a complex matrix \f$A\f$. The SVD algorithm computes |
---|
115 | * the decomposition of a complex \f$m \times n\f$ matrix \f$\mathbf{A}\f$ |
---|
116 | * so that |
---|
117 | * \f[ |
---|
118 | * \mathrm{diag}(\mathbf{U}^H \mathbf{A} \mathbf{V}) = \mathbf{s} |
---|
119 | * = \sigma_1, \ldots, \sigma_p |
---|
120 | * \f] |
---|
121 | * where \f$\sigma_1 \geq \sigma_2 \geq \ldots \sigma_p \geq 0\f$ |
---|
122 | * are the singular values of \f$\mathbf{A}\f$. |
---|
123 | * Or put differently: |
---|
124 | * \f[ |
---|
125 | * \mathbf{A} = \mathbf{U} \mathbf{S} \mathbf{V}^H |
---|
126 | * \f] |
---|
127 | * where \f$ \mathrm{diag}(\mathbf{S}) = \mathbf{s} \f$ |
---|
128 | * |
---|
129 | * \note An external LAPACK library is required by this function. |
---|
130 | */ |
---|
131 | vec svd(const cmat &A); |
---|
132 | |
---|
133 | /*! |
---|
134 | * \ingroup matrixdecomp |
---|
135 | * \brief Perform Singular Value Decomposition (SVD) of a real matrix \c A |
---|
136 | * |
---|
137 | * This function returns two orthonormal matrices \f$U\f$ and \f$V\f$ |
---|
138 | * and a vector of singular values \f$s\f$. |
---|
139 | * The SVD algorithm computes the decomposition of a real \f$m \times n\f$ |
---|
140 | * matrix \f$\mathbf{A}\f$ so that |
---|
141 | * \f[ |
---|
142 | * \mathrm{diag}(\mathbf{U}^T \mathbf{A} \mathbf{V}) = \mathbf{s} |
---|
143 | * = \sigma_1, \ldots, \sigma_p |
---|
144 | * \f] |
---|
145 | * where the elements of \f$\mathbf{s}\f$, \f$\sigma_1 \geq \sigma_2 \geq |
---|
146 | * \ldots \sigma_p \geq 0\f$ are the singular values of \f$\mathbf{A}\f$. |
---|
147 | * Or put differently: |
---|
148 | * \f[ |
---|
149 | * \mathbf{A} = \mathbf{U} \mathbf{S} \mathbf{V}^T |
---|
150 | * \f] |
---|
151 | * where \f$ \mathrm{diag}(\mathbf{S}) = \mathbf{s} \f$ |
---|
152 | * |
---|
153 | * \note An external LAPACK library is required by this function. |
---|
154 | */ |
---|
155 | bool svd(const mat &A, mat &U, vec &s, mat &V); |
---|
156 | |
---|
157 | /*! |
---|
158 | * \ingroup matrixdecomp |
---|
159 | * \brief Perform Singular Value Decomposition (SVD) of a complex matrix \c A |
---|
160 | * |
---|
161 | * This function returns two orthonormal matrices \f$U\f$ and \f$V\f$ |
---|
162 | * and a vector of singular values \f$s\f$. |
---|
163 | * The SVD algorithm computes the decomposition of a complex \f$m \times n\f$ |
---|
164 | * matrix \f$\mathbf{A}\f$ so that |
---|
165 | * \f[ |
---|
166 | * \mathrm{diag}(\mathbf{U}^H \mathbf{A} \mathbf{V}) = \mathbf{s} |
---|
167 | * = \sigma_1, \ldots, \sigma_p |
---|
168 | * \f] |
---|
169 | * where the elements of \f$\mathbf{s}\f$, \f$\sigma_1 \geq \sigma_2 \geq |
---|
170 | * \ldots \sigma_p \geq 0\f$ are the singular values of \f$\mathbf{A}\f$. |
---|
171 | * Or put differently: |
---|
172 | * \f[ |
---|
173 | * \mathbf{A} = \mathbf{U} \mathbf{S} \mathbf{V}^H |
---|
174 | * \f] |
---|
175 | * where \f$ \mathrm{diag}(\mathbf{S}) = \mathbf{s} \f$ |
---|
176 | * |
---|
177 | * \note An external LAPACK library is required by this function. |
---|
178 | */ |
---|
179 | bool svd(const cmat &A, cmat &U, vec &s, cmat &V); |
---|
180 | |
---|
181 | |
---|
182 | } // namespace itpp |
---|
183 | |
---|
184 | #endif // #ifndef SVD_H |
---|