MatrixType.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2006-2012 David Bateman
00004 Copyright (C) 2006 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 #if !defined (octave_MatrixType_h)
00025 #define octave_MatrixType_h
00026 
00027 class Matrix;
00028 class ComplexMatrix;
00029 class FloatMatrix;
00030 class FloatComplexMatrix;
00031 class SparseMatrix;
00032 class SparseComplexMatrix;
00033 
00034 class
00035 OCTAVE_API
00036 MatrixType
00037 {
00038 public:
00039   enum matrix_type {
00040     Unknown = 0,
00041     Full,
00042     Diagonal,
00043     Permuted_Diagonal,
00044     Upper,
00045     Lower,
00046     Permuted_Upper,
00047     Permuted_Lower,
00048     Banded,
00049     Hermitian,
00050     Banded_Hermitian,
00051     Tridiagonal,
00052     Tridiagonal_Hermitian,
00053     Rectangular
00054   };
00055 
00056   MatrixType (void);
00057 
00058   MatrixType (const MatrixType &a);
00059 
00060   MatrixType (const Matrix &a);
00061 
00062   MatrixType (const ComplexMatrix &a);
00063 
00064   MatrixType (const FloatMatrix &a);
00065 
00066   MatrixType (const FloatComplexMatrix &a);
00067 
00068   MatrixType (const SparseMatrix &a);
00069 
00070   MatrixType (const SparseComplexMatrix &a);
00071 
00072   MatrixType (const matrix_type t, bool _full = false);
00073 
00074   MatrixType (const matrix_type t, const octave_idx_type np,
00075               const octave_idx_type *p, bool _full = false);
00076 
00077   MatrixType (const matrix_type t, const octave_idx_type ku,
00078               const octave_idx_type kl, bool _full = false);
00079 
00080   ~MatrixType (void);
00081 
00082   MatrixType& operator = (const MatrixType& a);
00083 
00084   int type (bool quiet = true);
00085 
00086   int type (const Matrix &a);
00087 
00088   int type (const ComplexMatrix &a);
00089 
00090   int type (const FloatMatrix &a);
00091 
00092   int type (const FloatComplexMatrix &a);
00093 
00094   int type (const SparseMatrix &a);
00095 
00096   int type (const SparseComplexMatrix &a);
00097 
00098   double band_density (void) const { return bandden; }
00099 
00100   int nupper (void) const { return upper_band; }
00101 
00102   int nlower (void) const { return lower_band; }
00103 
00104   bool is_dense (void) const { return dense; }
00105 
00106   bool is_diagonal (void) const
00107     { return (typ == Diagonal || typ == Permuted_Diagonal); }
00108 
00109   bool is_upper_triangular (void) const
00110     { return (typ == Upper || typ == Permuted_Upper); }
00111 
00112   bool is_lower_triangular (void) const
00113     { return (typ == Lower || typ == Permuted_Lower); }
00114 
00115    bool is_banded (void)
00116     { return (typ == Banded || typ == Banded_Hermitian); }
00117 
00118   bool is_tridiagonal (void) const
00119     { return (typ == Tridiagonal || typ == Tridiagonal_Hermitian); }
00120 
00121   bool is_hermitian (void) const
00122     { return (typ == Banded_Hermitian || typ == Tridiagonal_Hermitian ||
00123               typ == Hermitian); }
00124 
00125   bool is_rectangular (void) const { return (typ == Rectangular); }
00126 
00127   bool is_known (void) const { return (typ != Unknown); }
00128 
00129   bool is_unknown (void) const { return (typ == Unknown); }
00130 
00131   void info (void) const;
00132 
00133   octave_idx_type * triangular_perm (void) const { return perm; }
00134 
00135   void invalidate_type (void) { typ = Unknown; }
00136 
00137   void mark_as_diagonal (void) { typ = Diagonal; }
00138 
00139   void mark_as_permuted_diagonal (void) { typ = Permuted_Diagonal; }
00140 
00141   void mark_as_upper_triangular (void) { typ = Upper; }
00142 
00143   void mark_as_lower_triangular (void) { typ = Lower; }
00144 
00145   void mark_as_tridiagonal (void) {typ = Tridiagonal; }
00146 
00147   void mark_as_banded (const octave_idx_type ku, const octave_idx_type kl)
00148     { typ = Banded; upper_band = ku; lower_band = kl; }
00149 
00150   void mark_as_full (void) { typ = Full; }
00151 
00152   void mark_as_rectangular (void) { typ = Rectangular; }
00153 
00154   void mark_as_dense (void) { dense = true; }
00155 
00156   void mark_as_not_dense (void) { dense = false; }
00157 
00158   void mark_as_symmetric (void);
00159 
00160   void mark_as_unsymmetric (void);
00161 
00162   void mark_as_permuted (const octave_idx_type np, const octave_idx_type *p);
00163 
00164   void mark_as_unpermuted (void);
00165 
00166   MatrixType transpose (void) const;
00167 
00168 private:
00169   void type (int new_typ) { typ = static_cast<matrix_type>(new_typ); }
00170 
00171   matrix_type typ;
00172   double sp_bandden;
00173   double bandden;
00174   octave_idx_type upper_band;
00175   octave_idx_type lower_band;
00176   bool dense;
00177   bool full;
00178   octave_idx_type nperm;
00179   octave_idx_type *perm;
00180 };
00181 
00182 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines