MyraMath
gesvd.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_DENSE_GESVD_H
7 #define MYRAMATH_DENSE_GESVD_H
8 
14 #include <myramath/MYRAMATH_EXPORT.h>
16 
17 #include <myramath/dense/Matrix.h>
19 
20 namespace myra {
21 
22 template<class Number> class CDiagonalMatrixRange;
23 
25 template<class Number> class gesvd_output
26  {
27  public:
28 
31 
34  {
35  U.swap(in_U);
36  S.swap(in_S);
37  V.swap(in_V);
38  }
39 
41  Matrix<Number> U; // Unitary U, U'U = I
42  DiagonalMatrix<Precision> S; // Real diagonal S
43  Matrix<Number> V; // Unitary V, VV' = I
44  };
45 
47 // Makes a deep copy of A, returns U,S,V in an gesvd_output<> tuple.
49 MYRAMATH_EXPORT gesvd_output<NumberS> gesvd(const CMatrixRange<NumberS>& A);
50 MYRAMATH_EXPORT gesvd_output<NumberD> gesvd(const CMatrixRange<NumberD>& A);
51 MYRAMATH_EXPORT gesvd_output<NumberC> gesvd(const CMatrixRange<NumberC>& A);
52 MYRAMATH_EXPORT gesvd_output<NumberZ> gesvd(const CMatrixRange<NumberZ>& A);
54 
56 // Overwrites U,S,V with the output. Clobbers A.
58 MYRAMATH_EXPORT void gesvd_inplace(const MatrixRange<NumberS>& A, const MatrixRange<NumberS>& U, const DiagonalMatrixRange<NumberS>& S, const MatrixRange<NumberS>& V);
59 MYRAMATH_EXPORT void gesvd_inplace(const MatrixRange<NumberD>& A, const MatrixRange<NumberD>& U, const DiagonalMatrixRange<NumberD>& S, const MatrixRange<NumberD>& V);
60 MYRAMATH_EXPORT void gesvd_inplace(const MatrixRange<NumberC>& A, const MatrixRange<NumberC>& U, const DiagonalMatrixRange<NumberS>& S, const MatrixRange<NumberC>& V);
61 MYRAMATH_EXPORT void gesvd_inplace(const MatrixRange<NumberZ>& A, const MatrixRange<NumberZ>& U, const DiagonalMatrixRange<NumberD>& S, const MatrixRange<NumberZ>& V);
63 
65 int rank(const CDiagonalMatrixRange<float >& S, float tolerance);
66 int rank(const CDiagonalMatrixRange<double>& S, double tolerance);
68 
69 } // namespace
70 
71 #endif
Represents a const DiagonalMatrixRange.
Definition: conjugate.h:35
Matrix< Number > U
Decomposes A = U*S*V.
Definition: gesvd.h:41
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
ReflectPrecision< Number >::type Precision
Useful typedefs.
Definition: gesvd.h:30
Return type of gesvd()
Definition: gesvd.h:25
Definition: syntax.dox:1
Represents a const MatrixRange.
Definition: bothcat.h:22
Various utility functions/classes related to scalar Number types.
Represents a mutable MatrixRange.
Definition: conjugate.h:26
void swap(DiagonalMatrix &that)
Member swap.
Definition: DiagonalMatrix.cpp:57
General purpose dense matrix container, O(i*j) storage.
gesvd_output(Matrix< Number > &in_U, DiagonalMatrix< Precision > &in_S, Matrix< Number > &in_V)
Swaps from components.
Definition: gesvd.h:33
Reflects Precision trait for a Number, scalar Number types should specialize it.
Definition: Number.h:33
Container for a diagonal matrix, O(n) storage. Used by SVD, row/column scaling, etc.
Represents a mutable DiagonalMatrixRange.
Definition: conjugate.h:29