Loading...
Searching...
No Matches
SVD.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::SVD
29
30Description
31 Singular value decomposition of a rectangular matrix.
32
33SourceFiles
34 SVD.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_SVD_H
39#define Foam_SVD_H
40
41#include "scalarMatrices.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// Forward Declarations
49template<class Cmpt> class Tensor;
51/*---------------------------------------------------------------------------*\
52 Class SVD Declaration
53\*---------------------------------------------------------------------------*/
54
55class SVD
56{
57 // Private Data
58
59 //- Rectangular matrix with the same dimensions as the input
61
62 //- Square matrix V
64
65 //- The singular values
67
68 //- Convergence flag
69 bool converged_;
70
71 //- The number of zero singular values
72 label nZeros_;
73
74
75public:
76
77 // Generated Methods
78
79 //- No copy construct
80 SVD(const SVD&) = delete;
81
82 //- No copy assignment
83 void operator=(const SVD&) = delete;
84
85
86 // Constructors
88 //- Construct from a rectangular Matrix
89 explicit SVD
90 (
92 const scalar minCondition = 0
93 );
94
95
96 // Access Functions
97
98 //- Return U
99 const scalarRectangularMatrix& U() const noexcept { return U_; }
100
101 //- Return the square matrix V
102 const scalarRectangularMatrix& V() const noexcept { return V_; }
103
104 //- Return the singular values
105 const scalarDiagonalMatrix& S() const noexcept { return S_; }
106
107 //- Return the minimum non-zero singular value
108 bool converged() const noexcept { return converged_; }
109
110 //- Return the number of zero singular values
111 label nZeros() const noexcept { return nZeros_; }
113 //- Return the minimum non-zero singular value
114 scalar minNonZeroS() const;
115
116
117 // Member Functions
118
119 //- Return the matrix product V S^(-1) U^T (the pseudo inverse)
121
123 // Static Member Functions
124
125 //- Return the pseudo inverse of the given matrix
129 const scalar minCondition = 0
130 );
131
132 //- Return the pseudo inverse of the given tensor
133 static Tensor<scalar> pinv
134 (
135 const Tensor<scalar>& A,
136 const scalar minCondition = 0
137 );
138};
139
140
141// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142
143} // End namespace Foam
144
145// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146
147#endif
148
149// ************************************************************************* //
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
A templated (N x N) diagonal matrix of objects of <Type>, effectively containing N elements,...
scalarRectangularMatrix VSinvUt() const
Return the matrix product V S^(-1) U^T (the pseudo inverse).
Definition SVD.C:479
void operator=(const SVD &)=delete
No copy assignment.
scalar minNonZeroS() const
Return the minimum non-zero singular value.
Definition SVD.C:467
const scalarRectangularMatrix & V() const noexcept
Return the square matrix V.
Definition SVD.H:117
bool converged() const noexcept
Return the minimum non-zero singular value.
Definition SVD.H:127
const scalarRectangularMatrix & U() const noexcept
Return U.
Definition SVD.H:112
const scalarDiagonalMatrix & S() const noexcept
Return the singular values.
Definition SVD.H:122
SVD(const SVD &)=delete
No copy construct.
label nZeros() const noexcept
Return the number of zero singular values.
Definition SVD.H:132
static scalarRectangularMatrix pinv(const scalarRectangularMatrix &A, const scalar minCondition=0)
Return the pseudo inverse of the given matrix.
Definition SVD.C:490
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
Definition Tensor.H:60
Namespace for OpenFOAM.
RectangularMatrix< scalar > scalarRectangularMatrix
DiagonalMatrix< scalar > scalarDiagonalMatrix
const direction noexcept
Definition scalarImpl.H:265