5785
|
1 /* |
|
2 |
|
3 Copyright (C) 2006 David Bateman |
|
4 Copyright (C) 2006 Andy Adler |
|
5 |
|
6 Octave is free software; you can redistribute it and/or modify it |
|
7 under the terms of the GNU General Public License as published by the |
|
8 Free Software Foundation; either version 2, or (at your option) any |
|
9 later version. |
|
10 |
|
11 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License |
|
17 along with this program; see the file COPYING. If not, write to the |
|
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 Boston, MA 02110-1301, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_MatrixType_h) |
|
24 #define octave_MatrixType_h |
|
25 |
|
26 class Matrix; |
|
27 class ComplexMatrix; |
|
28 class SparseMatrix; |
|
29 class SparseComplexMatrix; |
|
30 |
|
31 class |
|
32 MatrixType |
|
33 { |
|
34 public: |
|
35 enum matrix_type { |
|
36 Unknown = 0, |
|
37 Full, |
|
38 Diagonal, |
|
39 Permuted_Diagonal, |
|
40 Upper, |
|
41 Lower, |
|
42 Permuted_Upper, |
|
43 Permuted_Lower, |
|
44 Banded, |
|
45 Hermitian, |
|
46 Banded_Hermitian, |
|
47 Tridiagonal, |
|
48 Tridiagonal_Hermitian, |
|
49 Rectangular |
|
50 }; |
|
51 |
|
52 MatrixType (void); |
|
53 |
|
54 MatrixType (const MatrixType &a); |
|
55 |
|
56 MatrixType (const Matrix &a); |
|
57 |
|
58 MatrixType (const ComplexMatrix &a); |
|
59 |
|
60 MatrixType (const SparseMatrix &a); |
|
61 |
|
62 MatrixType (const SparseComplexMatrix &a); |
|
63 |
|
64 MatrixType (const matrix_type t, bool _full = false); |
|
65 |
|
66 MatrixType (const matrix_type t, const octave_idx_type np, |
|
67 const octave_idx_type *p, bool _full = false); |
|
68 |
|
69 MatrixType (const matrix_type t, const octave_idx_type ku, |
|
70 const octave_idx_type kl, bool _full = false); |
|
71 |
|
72 ~MatrixType (void); |
|
73 |
|
74 MatrixType& operator = (const MatrixType& a); |
|
75 |
|
76 int type (bool quiet = true); |
|
77 |
|
78 int type (const Matrix &a); |
|
79 |
|
80 int type (const ComplexMatrix &a); |
|
81 |
|
82 int type (const SparseMatrix &a); |
|
83 |
|
84 int type (const SparseComplexMatrix &a); |
|
85 |
|
86 double band_density (void) const { return bandden; } |
|
87 |
|
88 int nupper (void) const { return upper_band; } |
|
89 |
|
90 int nlower (void) const { return lower_band; } |
|
91 |
|
92 bool is_dense (void) const { return dense; } |
|
93 |
|
94 bool is_diagonal (void) const |
|
95 { return (typ == Diagonal || typ == Permuted_Diagonal); } |
|
96 |
|
97 bool is_upper_triangular (void) const |
|
98 { return (typ == Upper || typ == Permuted_Upper); } |
|
99 |
|
100 bool is_lower_triangular (void) const |
|
101 { return (typ == Lower || typ == Permuted_Lower); } |
|
102 |
|
103 bool is_banded (void) |
|
104 { return (typ == Banded || typ == Banded_Hermitian); } |
|
105 |
|
106 bool is_tridiagonal (void) const |
|
107 { return (typ == Tridiagonal || typ == Tridiagonal_Hermitian); } |
|
108 |
|
109 bool is_hermitian (void) const |
|
110 { return (typ == Banded_Hermitian || typ == Tridiagonal_Hermitian || |
|
111 typ == Hermitian); } |
|
112 |
|
113 bool is_rectangular (void) const { return (typ == Rectangular); } |
|
114 |
|
115 bool is_known (void) const { return (typ != Unknown); } |
|
116 |
|
117 bool is_unknown (void) const { return (typ == Unknown); } |
|
118 |
|
119 void info (void) const; |
|
120 |
|
121 octave_idx_type * triangular_perm (void) const { return perm; } |
|
122 |
|
123 void invalidate_type (void) { typ = Unknown; } |
|
124 |
|
125 void mark_as_diagonal (void) { typ = Diagonal; } |
|
126 |
|
127 void mark_as_permuted_diagonal (void) { typ = Permuted_Diagonal; } |
|
128 |
|
129 void mark_as_upper_triangular (void) { typ = Upper; } |
|
130 |
|
131 void mark_as_lower_triangular (void) { typ = Lower; } |
|
132 |
|
133 void mark_as_tridiagonal (void) {typ = Tridiagonal; } |
|
134 |
|
135 void mark_as_banded (const octave_idx_type ku, const octave_idx_type kl) |
|
136 { typ = Banded; upper_band = ku; lower_band = kl; } |
|
137 |
|
138 void mark_as_full (void) { typ = Full; } |
|
139 |
|
140 void mark_as_rectangular (void) { typ = Rectangular; } |
|
141 |
|
142 void mark_as_dense (void) { dense = true; } |
|
143 |
|
144 void mark_as_not_dense (void) { dense = false; } |
|
145 |
|
146 void mark_as_symmetric (void); |
|
147 |
|
148 void mark_as_unsymmetric (void); |
|
149 |
|
150 void mark_as_permuted (const octave_idx_type np, const octave_idx_type *p); |
|
151 |
|
152 void mark_as_unpermuted (void); |
|
153 |
|
154 MatrixType transpose (void) const; |
|
155 |
|
156 private: |
|
157 void type (int new_typ) { typ = static_cast<matrix_type>(new_typ); } |
|
158 |
|
159 matrix_type typ; |
|
160 double sp_bandden; |
|
161 double bandden; |
|
162 octave_idx_type upper_band; |
|
163 octave_idx_type lower_band; |
|
164 bool dense; |
|
165 bool full; |
|
166 octave_idx_type nperm; |
|
167 octave_idx_type *perm; |
|
168 }; |
|
169 |
|
170 #endif |
|
171 |
|
172 /* |
|
173 ;;; Local Variables: *** |
|
174 ;;; mode: C++ *** |
|
175 ;;; End: *** |
|
176 */ |