[4ede1e]: itpp / base / algebra / svd.h Maximize Restore History

Download this file

svd.h    185 lines (171 with data), 6.1 kB

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