00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::SVD 00026 00027 Description 00028 Singular value decomposition of a rectangular matrix. 00029 00030 SourceFiles 00031 SVDI.H 00032 SVD.C 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef SVD_H 00037 #define SVD_H 00038 00039 #include <OpenFOAM/scalarMatrices.H> 00040 00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00042 00043 namespace Foam 00044 { 00045 00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00047 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class SVD Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class SVD 00054 { 00055 // Private data 00056 00057 //- Rectangular matrix with the same dimensions as the input 00058 scalarRectangularMatrix U_; 00059 00060 //- square matrix V 00061 scalarRectangularMatrix V_; 00062 00063 //- The singular values 00064 DiagonalMatrix<scalar> S_; 00065 00066 //- The matrix product V S^(-1) U^T 00067 scalarRectangularMatrix VSinvUt_; 00068 00069 //- The number of zero singular values 00070 label nZeros_; 00071 00072 00073 // Private Member Functions 00074 00075 //- Disallow default bitwise copy construct 00076 SVD(const SVD&); 00077 00078 //- Disallow default bitwise assignment 00079 void operator=(const SVD&); 00080 00081 template<class T> 00082 inline const T sign(const T& a, const T& b); 00083 00084 00085 public: 00086 00087 // Constructors 00088 00089 //- Construct from a rectangular Matrix 00090 SVD(const scalarRectangularMatrix& A, const scalar minCondition = 0); 00091 00092 00093 // Access functions 00094 00095 //- Return U 00096 inline const scalarRectangularMatrix& U() const; 00097 00098 //- Return the square matrix V 00099 inline const scalarRectangularMatrix& V() const; 00100 00101 //- Return the singular values 00102 inline const scalarDiagonalMatrix& S() const; 00103 00104 //- Return VSinvUt (the pseudo inverse) 00105 inline const scalarRectangularMatrix& VSinvUt() const; 00106 00107 //- Return the number of zero singular values 00108 inline label nZeros() const; 00109 00110 //- Return the minimum non-zero singular value 00111 inline scalar minNonZeroS() const; 00112 }; 00113 00114 00115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00116 00117 } // End namespace Foam 00118 00119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00120 00121 #include "SVDI.H" 00122 00123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00124 00125 #endif 00126 00127 // ************************ vim: set sw=4 sts=4 et: ************************ //