GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatrixType.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2006-2024 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 "mx-fwd.h"
32 
33 #include "MSparse.h"
34 
35 class
37 {
38 public:
40  {
41  Unknown = 0,
54  Rectangular
55  };
56 
58 
59  OCTAVE_API MatrixType (const MatrixType& a);
60 
61  OCTAVE_API MatrixType (const Matrix& a);
62 
64 
66 
68 
69  template <typename T>
71  MatrixType (const MSparse<T>& a);
72 
73  OCTAVE_API MatrixType (const matrix_type t, bool _full = false);
74 
75  OCTAVE_API MatrixType (const matrix_type t, const octave_idx_type np,
76  const octave_idx_type *p, bool _full = false);
77 
78  OCTAVE_API MatrixType (const matrix_type t, const octave_idx_type ku,
79  const octave_idx_type kl, bool _full = false);
80 
82 
83  OCTAVE_API MatrixType& operator = (const MatrixType& a);
84 
85  OCTAVE_API int type (bool quiet = true);
86 
87  OCTAVE_API int type (const Matrix& a);
88 
89  OCTAVE_API int type (const ComplexMatrix& a);
90 
91  OCTAVE_API int type (const FloatMatrix& a);
92 
93  OCTAVE_API int type (const FloatComplexMatrix& a);
94 
95  OCTAVE_API int type (const SparseMatrix& a);
96 
97  OCTAVE_API int type (const SparseComplexMatrix& a);
98 
99  double band_density () const { return m_bandden; }
100 
101  int nupper () const { return m_upper_band; }
102 
103  int nlower () const { return m_lower_band; }
104 
105  bool is_dense () const { return m_dense; }
106 
107  bool isdiag () const
108  { return (m_type == Diagonal || m_type == Permuted_Diagonal); }
109 
110  bool istriu () const
111  { return (m_type == Upper || m_type == Permuted_Upper); }
112 
113  bool istril () const
114  { return (m_type == Lower || m_type == Permuted_Lower); }
115 
116  bool isbanded () const
117  { return (m_type == Banded || m_type == Banded_Hermitian); }
118 
119  bool is_tridiagonal () const
120  { return (m_type == Tridiagonal || m_type == Tridiagonal_Hermitian); }
121 
122  bool ishermitian () const
123  {
124  return (m_type == Banded_Hermitian || m_type == Tridiagonal_Hermitian
125  || m_type == Hermitian);
126  }
127 
128  bool is_rectangular () const { return (m_type == Rectangular); }
129 
130  bool is_known () const { return (m_type != Unknown); }
131 
132  bool is_unknown () const { return (m_type == Unknown); }
133 
134  OCTAVE_API void info () const;
135 
136  octave_idx_type * triangular_perm () const { return m_perm; }
137 
138  void invalidate_type () { m_type = Unknown; }
139 
140  void mark_as_diagonal () { m_type = Diagonal; }
141 
142  void mark_as_permuted_diagonal () { m_type = Permuted_Diagonal; }
143 
144  void mark_as_upper_triangular () { m_type = Upper; }
145 
146  void mark_as_lower_triangular () { m_type = Lower; }
147 
148  void mark_as_tridiagonal () {m_type = Tridiagonal; }
149 
151  { m_type = Banded; m_upper_band = ku; m_lower_band = kl; }
152 
153  void mark_as_full () { m_type = Full; }
154 
155  void mark_as_rectangular () { m_type = Rectangular; }
156 
157  void mark_as_dense () { m_dense = true; }
158 
159  void mark_as_not_dense () { m_dense = false; }
160 
161  OCTAVE_API void mark_as_symmetric ();
162 
163  OCTAVE_API void mark_as_unsymmetric ();
164 
165  OCTAVE_API void mark_as_permuted (const octave_idx_type np, const octave_idx_type *p);
166 
167  OCTAVE_API void mark_as_unpermuted ();
168 
169  OCTAVE_API MatrixType transpose () const;
170 
171 private:
172  void type (int new_typ) { m_type = static_cast<matrix_type> (new_typ); }
173 
174  matrix_type m_type;
175  double m_sp_bandden;
176  double m_bandden;
177  octave_idx_type m_upper_band;
178  octave_idx_type m_lower_band;
179  bool m_dense;
180  bool m_full;
181  octave_idx_type m_nperm;
182  octave_idx_type *m_perm;
183 };
184 
185 #endif
bool is_known() const
Definition: MatrixType.h:130
bool ishermitian() const
Definition: MatrixType.h:122
void mark_as_not_dense()
Definition: MatrixType.h:159
void invalidate_type()
Definition: MatrixType.h:138
bool istriu() const
Definition: MatrixType.h:110
@ Tridiagonal_Hermitian
Definition: MatrixType.h:53
@ Permuted_Lower
Definition: MatrixType.h:48
@ Banded_Hermitian
Definition: MatrixType.h:51
@ Permuted_Diagonal
Definition: MatrixType.h:44
@ Permuted_Upper
Definition: MatrixType.h:47
double band_density() const
Definition: MatrixType.h:99
void mark_as_tridiagonal()
Definition: MatrixType.h:148
octave_idx_type * triangular_perm() const
Definition: MatrixType.h:136
int nupper() const
Definition: MatrixType.h:101
void mark_as_banded(const octave_idx_type ku, const octave_idx_type kl)
Definition: MatrixType.h:150
bool isdiag() const
Definition: MatrixType.h:107
bool is_unknown() const
Definition: MatrixType.h:132
void mark_as_full()
Definition: MatrixType.h:153
int nlower() const
Definition: MatrixType.h:103
bool isbanded() const
Definition: MatrixType.h:116
void mark_as_dense()
Definition: MatrixType.h:157
void mark_as_upper_triangular()
Definition: MatrixType.h:144
void mark_as_permuted_diagonal()
Definition: MatrixType.h:142
void mark_as_lower_triangular()
Definition: MatrixType.h:146
bool is_tridiagonal() const
Definition: MatrixType.h:119
bool istril() const
Definition: MatrixType.h:113
void mark_as_rectangular()
Definition: MatrixType.h:155
void mark_as_diagonal()
Definition: MatrixType.h:140
bool is_rectangular() const
Definition: MatrixType.h:128
bool is_dense() const
Definition: MatrixType.h:105
Definition: dMatrix.h:42
#define OCTAVE_API
Definition: main.cc:55