floatCHOL.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1994-2012 John W. Eaton
00004 Copyright (C) 2008-2009 Jaroslav Hajek
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (octave_FloatCHOL_h)
00025 #define octave_FloatCHOL_h 1
00026 
00027 #include <iosfwd>
00028 
00029 #include "fMatrix.h"
00030 #include "fColVector.h"
00031 
00032 class
00033 OCTAVE_API
00034 FloatCHOL
00035 {
00036 public:
00037 
00038   FloatCHOL (void) : chol_mat (), xrcond (0) { }
00039 
00040   FloatCHOL (const FloatMatrix& a, bool calc_cond = false)
00041     : chol_mat (), xrcond (0)
00042     {
00043       init (a, calc_cond);
00044     }
00045 
00046   FloatCHOL (const FloatMatrix& a, octave_idx_type& info,
00047              bool calc_cond = false)
00048     : chol_mat (), xrcond (0)
00049     {
00050       info = init (a, calc_cond);
00051     }
00052 
00053   FloatCHOL (const FloatCHOL& a) : chol_mat (a.chol_mat), xrcond (a.xrcond) { }
00054 
00055   FloatCHOL& operator = (const FloatCHOL& a)
00056     {
00057       if (this != &a)
00058         {
00059           chol_mat = a.chol_mat;
00060           xrcond = a.xrcond;
00061         }
00062       return *this;
00063     }
00064 
00065   FloatMatrix chol_matrix (void) const { return chol_mat; }
00066 
00067   float rcond (void) const { return xrcond; }
00068 
00069   // Compute the inverse of a matrix using the Cholesky factorization.
00070   FloatMatrix inverse (void) const;
00071 
00072   void set (const FloatMatrix& R);
00073 
00074   void update (const FloatColumnVector& u);
00075 
00076   octave_idx_type downdate (const FloatColumnVector& u);
00077 
00078   octave_idx_type insert_sym (const FloatColumnVector& u, octave_idx_type j);
00079 
00080   void delete_sym (octave_idx_type j);
00081 
00082   void shift_sym (octave_idx_type i, octave_idx_type j);
00083 
00084   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatCHOL& a);
00085 
00086 private:
00087 
00088   FloatMatrix chol_mat;
00089 
00090   float xrcond;
00091 
00092   octave_idx_type init (const FloatMatrix& a, bool calc_cond);
00093 };
00094 
00095 FloatMatrix OCTAVE_API chol2inv (const FloatMatrix& r);
00096 
00097 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines