GNU Octave  4.4.1
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-2018 David Bateman
4 Copyright (C) 2006 Andy Adler
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_MatrixType_h)
25 #define octave_MatrixType_h 1
26 
27 #include "octave-config.h"
28 
29 #include "MSparse.h"
30 
31 class Matrix;
32 class ComplexMatrix;
33 class FloatMatrix;
34 class FloatComplexMatrix;
35 class SparseMatrix;
37 
38 class
39 OCTAVE_API
41 {
42 public:
44  {
45  Unknown = 0,
58  Rectangular
59  };
60 
61  MatrixType (void);
62 
63  MatrixType (const MatrixType& a);
64 
65  MatrixType (const Matrix& a);
66 
67  MatrixType (const ComplexMatrix& a);
68 
69  MatrixType (const FloatMatrix& a);
70 
72 
73  template <typename T>
74  MatrixType (const MSparse<T> &a);
75 
76  MatrixType (const matrix_type t, bool _full = false);
77 
78  MatrixType (const matrix_type t, const octave_idx_type np,
79  const octave_idx_type *p, bool _full = false);
80 
81  MatrixType (const matrix_type t, const octave_idx_type ku,
82  const octave_idx_type kl, bool _full = false);
83 
84  ~MatrixType (void);
85 
87 
88  int type (bool quiet = true);
89 
90  int type (const Matrix& a);
91 
92  int type (const ComplexMatrix& a);
93 
94  int type (const FloatMatrix& a);
95 
96  int type (const FloatComplexMatrix& a);
97 
98  int type (const SparseMatrix& a);
99 
100  int type (const SparseComplexMatrix& a);
101 
102  double band_density (void) const { return bandden; }
103 
104  int nupper (void) const { return upper_band; }
105 
106  int nlower (void) const { return lower_band; }
107 
108  bool is_dense (void) const { return dense; }
109 
110  bool isdiag (void) const
111  { return (typ == Diagonal || typ == Permuted_Diagonal); }
112 
113  OCTAVE_DEPRECATED (4.4, "use 'isdiag' instead")
114  bool is_diagonal (void) const
115  { return isdiag (); }
116 
117  bool istriu (void) const
118  { return (typ == Upper || typ == Permuted_Upper); }
119 
120  OCTAVE_DEPRECATED (4.4, "use 'istriu' instead")
121  bool is_upper_triangular (void) const
122  { return istriu (); }
123 
124  bool istril (void) const
125  { return (typ == Lower || typ == Permuted_Lower); }
126 
127  OCTAVE_DEPRECATED (4.4, "use 'istril' instead")
128  bool is_lower_triangular (void) const
129  { return istril (); }
130 
131  bool isbanded (void) const
132  { return (typ == Banded || typ == Banded_Hermitian); }
133 
134  OCTAVE_DEPRECATED (4.4, "use 'isbanded' instead")
135  bool is_banded (void) const
136  { return isbanded (); }
137 
138  bool is_tridiagonal (void) const
139  { return (typ == Tridiagonal || typ == Tridiagonal_Hermitian); }
140 
141  bool ishermitian (void) const
142  {
143  return (typ == Banded_Hermitian || typ == Tridiagonal_Hermitian
144  || typ == Hermitian);
145  }
146 
147  OCTAVE_DEPRECATED (4.4, "use 'ishermitian' instead")
148  bool is_hermitian (void) const
149  { return ishermitian (); }
150 
151  bool is_rectangular (void) const { return (typ == Rectangular); }
152 
153  bool is_known (void) const { return (typ != Unknown); }
154 
155  bool is_unknown (void) const { return (typ == Unknown); }
156 
157  void info (void) const;
158 
159  octave_idx_type * triangular_perm (void) const { return perm; }
160 
161  void invalidate_type (void) { typ = Unknown; }
162 
163  void mark_as_diagonal (void) { typ = Diagonal; }
164 
165  void mark_as_permuted_diagonal (void) { typ = Permuted_Diagonal; }
166 
167  void mark_as_upper_triangular (void) { typ = Upper; }
168 
169  void mark_as_lower_triangular (void) { typ = Lower; }
170 
171  void mark_as_tridiagonal (void) {typ = Tridiagonal; }
172 
174  { typ = Banded; upper_band = ku; lower_band = kl; }
175 
176  void mark_as_full (void) { typ = Full; }
177 
178  void mark_as_rectangular (void) { typ = Rectangular; }
179 
180  void mark_as_dense (void) { dense = true; }
181 
182  void mark_as_not_dense (void) { dense = false; }
183 
184  void mark_as_symmetric (void);
185 
186  void mark_as_unsymmetric (void);
187 
188  void mark_as_permuted (const octave_idx_type np, const octave_idx_type *p);
189 
190  void mark_as_unpermuted (void);
191 
192  MatrixType transpose (void) const;
193 
194 private:
195  void type (int new_typ) { typ = static_cast<matrix_type>(new_typ); }
196 
198  double sp_bandden;
199  double bandden;
202  bool dense;
203  bool full;
206 };
207 
208 #endif
void mark_as_lower_triangular(void)
Definition: MatrixType.h:169
void mark_as_diagonal(void)
Definition: MatrixType.h:163
bool ishermitian(void) const
Definition: MatrixType.h:141
bool ishermitian(void) const
Definition: CSparse.cc:141
double sp_bandden
Definition: MatrixType.h:198
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:386
octave_idx_type * triangular_perm(void) const
Definition: MatrixType.h:159
void mark_as_permuted_diagonal(void)
Definition: MatrixType.h:165
bool is_unknown(void) const
Definition: MatrixType.h:155
bool istril(void) const
Definition: MatrixType.h:124
void mark_as_full(void)
Definition: MatrixType.h:176
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
bool dense
Definition: MatrixType.h:202
bool istriu(void) const
Definition: MatrixType.h:117
octave_idx_type lower_band
Definition: MatrixType.h:201
bool is_hermitian(void) const
Definition: CSparse.h:117
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
void type(int new_typ)
Definition: MatrixType.h:195
octave_idx_type upper_band
Definition: MatrixType.h:200
int nupper(void) const
Definition: MatrixType.h:104
octave_idx_type nperm
Definition: MatrixType.h:204
void mark_as_upper_triangular(void)
Definition: MatrixType.h:167
void mark_as_dense(void)
Definition: MatrixType.h:180
idx type
Definition: ov.cc:3114
Definition: dMatrix.h:36
matrix_type typ
Definition: MatrixType.h:197
bool is_rectangular(void) const
Definition: MatrixType.h:151
void mark_as_rectangular(void)
Definition: MatrixType.h:178
void invalidate_type(void)
Definition: MatrixType.h:161
octave_idx_type * perm
Definition: MatrixType.h:205
bool is_dense(void) const
Definition: MatrixType.h:108
bool is_tridiagonal(void) const
Definition: MatrixType.h:138
bool isbanded(void) const
Definition: MatrixType.h:131
p
Definition: lu.cc:138
void mark_as_not_dense(void)
Definition: MatrixType.h:182
int nlower(void) const
Definition: MatrixType.h:106
bool is_known(void) const
Definition: MatrixType.h:153
bool isdiag(void) const
Definition: MatrixType.h:110
void mark_as_tridiagonal(void)
Definition: MatrixType.h:171
double band_density(void) const
Definition: MatrixType.h:102
void mark_as_banded(const octave_idx_type ku, const octave_idx_type kl)
Definition: MatrixType.h:173
double bandden
Definition: MatrixType.h:199
SparseComplexMatrix & operator=(const SparseComplexMatrix &a)
Definition: CSparse.h:105