GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
MatrixType.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2006-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_MatrixType_h)
27 #define octave_MatrixType_h 1
28 
29 #include "octave-config.h"
30 
31 #include "MSparse.h"
32 
33 class Matrix;
34 class ComplexMatrix;
35 class FloatMatrix;
36 class FloatComplexMatrix;
37 class SparseMatrix;
39 
40 class
41 OCTAVE_API
43 {
44 public:
46  {
47  Unknown = 0,
60  Rectangular
61  };
62 
63  MatrixType (void);
64 
65  MatrixType (const MatrixType& a);
66 
67  MatrixType (const Matrix& a);
68 
69  MatrixType (const ComplexMatrix& a);
70 
71  MatrixType (const FloatMatrix& a);
72 
73  MatrixType (const FloatComplexMatrix& a);
74 
75  template <typename T>
76  MatrixType (const MSparse<T> &a);
77 
78  MatrixType (const matrix_type t, bool _full = false);
79 
80  MatrixType (const matrix_type t, const octave_idx_type np,
81  const octave_idx_type *p, bool _full = false);
82 
83  MatrixType (const matrix_type t, const octave_idx_type ku,
84  const octave_idx_type kl, bool _full = false);
85 
86  ~MatrixType (void);
87 
89 
90  int type (bool quiet = true);
91 
92  int type (const Matrix& a);
93 
94  int type (const ComplexMatrix& a);
95 
96  int type (const FloatMatrix& a);
97 
98  int type (const FloatComplexMatrix& a);
99 
100  int type (const SparseMatrix& a);
101 
102  int type (const SparseComplexMatrix& a);
103 
104  double band_density (void) const { return bandden; }
105 
106  int nupper (void) const { return upper_band; }
107 
108  int nlower (void) const { return lower_band; }
109 
110  bool is_dense (void) const { return dense; }
111 
112  bool isdiag (void) const
113  { return (typ == Diagonal || typ == Permuted_Diagonal); }
114 
115  bool istriu (void) const
116  { return (typ == Upper || typ == Permuted_Upper); }
117 
118  bool istril (void) const
119  { return (typ == Lower || typ == Permuted_Lower); }
120 
121  bool isbanded (void) const
122  { return (typ == Banded || typ == Banded_Hermitian); }
123 
124  bool is_tridiagonal (void) const
125  { return (typ == Tridiagonal || typ == Tridiagonal_Hermitian); }
126 
127  bool ishermitian (void) const
128  {
129  return (typ == Banded_Hermitian || typ == Tridiagonal_Hermitian
130  || typ == Hermitian);
131  }
132 
133  bool is_rectangular (void) const { return (typ == Rectangular); }
134 
135  bool is_known (void) const { return (typ != Unknown); }
136 
137  bool is_unknown (void) const { return (typ == Unknown); }
138 
139  void info (void) const;
140 
141  octave_idx_type * triangular_perm (void) const { return perm; }
142 
143  void invalidate_type (void) { typ = Unknown; }
144 
145  void mark_as_diagonal (void) { typ = Diagonal; }
146 
147  void mark_as_permuted_diagonal (void) { typ = Permuted_Diagonal; }
148 
149  void mark_as_upper_triangular (void) { typ = Upper; }
150 
151  void mark_as_lower_triangular (void) { typ = Lower; }
152 
153  void mark_as_tridiagonal (void) {typ = Tridiagonal; }
154 
156  { typ = Banded; upper_band = ku; lower_band = kl; }
157 
158  void mark_as_full (void) { typ = Full; }
159 
160  void mark_as_rectangular (void) { typ = Rectangular; }
161 
162  void mark_as_dense (void) { dense = true; }
163 
164  void mark_as_not_dense (void) { dense = false; }
165 
166  void mark_as_symmetric (void);
167 
168  void mark_as_unsymmetric (void);
169 
170  void mark_as_permuted (const octave_idx_type np, const octave_idx_type *p);
171 
172  void mark_as_unpermuted (void);
173 
174  MatrixType transpose (void) const;
175 
176 private:
177  void type (int new_typ) { typ = static_cast<matrix_type> (new_typ); }
178 
180  double sp_bandden;
181  double bandden;
184  bool dense;
185  bool full;
188 };
189 
190 #endif
double band_density(void) const
Definition: MatrixType.h:104
void mark_as_not_dense(void)
Definition: MatrixType.h:164
void mark_as_full(void)
Definition: MatrixType.h:158
void invalidate_type(void)
Definition: MatrixType.h:143
void mark_as_permuted_diagonal(void)
Definition: MatrixType.h:147
bool isdiag(void) const
Definition: MatrixType.h:112
bool ishermitian(void) const
Definition: MatrixType.h:127
void mark_as_rectangular(void)
Definition: MatrixType.h:160
bool is_dense(void) const
Definition: MatrixType.h:110
@ Tridiagonal_Hermitian
Definition: MatrixType.h:59
@ Permuted_Lower
Definition: MatrixType.h:54
@ Banded_Hermitian
Definition: MatrixType.h:57
@ Permuted_Diagonal
Definition: MatrixType.h:50
@ Permuted_Upper
Definition: MatrixType.h:53
octave_idx_type * triangular_perm(void) const
Definition: MatrixType.h:141
bool is_unknown(void) const
Definition: MatrixType.h:137
octave_idx_type lower_band
Definition: MatrixType.h:183
void mark_as_dense(void)
Definition: MatrixType.h:162
void mark_as_upper_triangular(void)
Definition: MatrixType.h:149
matrix_type typ
Definition: MatrixType.h:179
bool dense
Definition: MatrixType.h:184
bool is_rectangular(void) const
Definition: MatrixType.h:133
double sp_bandden
Definition: MatrixType.h:180
void mark_as_banded(const octave_idx_type ku, const octave_idx_type kl)
Definition: MatrixType.h:155
int nupper(void) const
Definition: MatrixType.h:106
int nlower(void) const
Definition: MatrixType.h:108
bool istriu(void) const
Definition: MatrixType.h:115
void mark_as_lower_triangular(void)
Definition: MatrixType.h:151
bool is_tridiagonal(void) const
Definition: MatrixType.h:124
void mark_as_tridiagonal(void)
Definition: MatrixType.h:153
bool isbanded(void) const
Definition: MatrixType.h:121
octave_idx_type nperm
Definition: MatrixType.h:186
octave_idx_type upper_band
Definition: MatrixType.h:182
void type(int new_typ)
Definition: MatrixType.h:177
bool istril(void) const
Definition: MatrixType.h:118
octave_idx_type * perm
Definition: MatrixType.h:187
bool is_known(void) const
Definition: MatrixType.h:135
double bandden
Definition: MatrixType.h:181
void mark_as_diagonal(void)
Definition: MatrixType.h:145
Definition: dMatrix.h:42
SparseComplexMatrix & operator=(const SparseComplexMatrix &a)
Definition: CSparse.h:107
static void transpose(octave_idx_type N, const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *ridx2, octave_idx_type *cidx2)
Definition: symrcm.cc:389