dbleSVD.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1994-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_SVD_h)
00024 #define octave_SVD_h 1
00025 
00026 #include <iosfwd>
00027 
00028 #include "dDiagMatrix.h"
00029 #include "dMatrix.h"
00030 
00031 class
00032 OCTAVE_API
00033 SVD
00034 {
00035 public:
00036 
00037   enum type
00038     {
00039       std,
00040       economy,
00041       sigma_only
00042     };
00043 
00044   enum driver
00045     {
00046       GESVD,
00047       GESDD
00048     };
00049 
00050   SVD (void) : type_computed (), sigma (), left_sm (), right_sm () { }
00051 
00052   SVD (const Matrix& a,
00053        type svd_type = SVD::std, driver svd_driver = SVD::GESVD)
00054     : type_computed (), sigma (), left_sm (), right_sm ()
00055     {
00056       init (a, svd_type, svd_driver);
00057     }
00058 
00059   SVD (const Matrix& a, octave_idx_type& info,
00060        type svd_type = SVD::std, driver svd_driver = SVD::GESVD)
00061     : type_computed (), sigma (), left_sm (), right_sm ()
00062     {
00063       info = init (a, svd_type, svd_driver);
00064     }
00065 
00066   SVD (const SVD& a)
00067     : type_computed (a.type_computed), sigma (a.sigma),
00068       left_sm (a.left_sm), right_sm (a.right_sm)
00069     { }
00070 
00071   SVD& operator = (const SVD& a)
00072     {
00073       if (this != &a)
00074         {
00075           type_computed = a.type_computed;
00076           sigma = a.sigma;
00077           left_sm = a.left_sm;
00078           right_sm = a.right_sm;
00079         }
00080 
00081       return *this;
00082     }
00083 
00084   ~SVD (void) { }
00085 
00086   DiagMatrix singular_values (void) const { return sigma; }
00087 
00088   Matrix left_singular_matrix (void) const;
00089 
00090   Matrix right_singular_matrix (void) const;
00091 
00092   friend std::ostream&  operator << (std::ostream& os, const SVD& a);
00093 
00094 private:
00095 
00096   SVD::type type_computed;
00097 
00098   DiagMatrix sigma;
00099   Matrix left_sm;
00100   Matrix right_sm;
00101 
00102   octave_idx_type init (const Matrix& a,
00103                         type svd_type = std, driver svd_driver = GESVD);
00104 };
00105 
00106 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines