sparse-base-lu.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2004-2012 David Bateman
00004 Copyright (C) 1998-2004 Andy Adler
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 
00025 #if !defined (octave_sparse_base_lu_h)
00026 #define octave_sparse_base_lu_h 1
00027 
00028 #include "MArray.h"
00029 #include "dSparse.h"
00030 
00031 template <class lu_type, class lu_elt_type, class p_type, class p_elt_type>
00032 class
00033 sparse_base_lu
00034 {
00035 public:
00036 
00037   sparse_base_lu (void)
00038     : Lfact (), Ufact (), Rfact (), cond (0), P (), Q () { }
00039 
00040   sparse_base_lu (const sparse_base_lu& a)
00041     : Lfact (a.Lfact), Ufact (a.Ufact), Rfact (), cond (a.cond),
00042     P (a.P), Q (a.Q)
00043     { }
00044 
00045   sparse_base_lu& operator = (const sparse_base_lu& a)
00046     {
00047       if (this != &a)
00048         {
00049           Lfact = a.Lfact;
00050           Ufact = a.Ufact;
00051           cond = a.cond;
00052           P = a.P;
00053           Q = a.Q;
00054         }
00055       return *this;
00056     }
00057 
00058   virtual ~sparse_base_lu (void) { }
00059 
00060   lu_type L (void) const { return Lfact; }
00061 
00062   lu_type U (void) const { return Ufact; }
00063 
00064   SparseMatrix R (void) const { return Rfact; }
00065 
00066   lu_type Y (void) const;
00067 
00068   p_type Pc (void) const;
00069 
00070   p_type Pr (void) const;
00071 
00072   ColumnVector Pc_vec (void) const;
00073 
00074   ColumnVector Pr_vec (void) const;
00075 
00076   PermMatrix Pc_mat (void) const;
00077 
00078   PermMatrix Pr_mat (void) const;
00079 
00080   const octave_idx_type * row_perm (void) const { return P.fortran_vec (); }
00081 
00082   const octave_idx_type * col_perm (void) const { return Q.fortran_vec (); }
00083 
00084   double rcond (void) const { return cond; }
00085 
00086 protected:
00087 
00088   lu_type Lfact;
00089   lu_type Ufact;
00090   SparseMatrix Rfact;
00091 
00092   double cond;
00093 
00094   MArray<octave_idx_type> P;
00095   MArray<octave_idx_type> Q;
00096 };
00097 
00098 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines