5164
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 David Bateman |
|
4 Copyright (C) 1998-2004 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 |
5307
|
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. |
5164
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_SparseType_h) |
|
24 #define octave_SparseType_h |
|
25 |
|
26 class SparseMatrix; |
|
27 class SparseComplexMatrix; |
|
28 |
|
29 class |
|
30 SparseType |
|
31 { |
|
32 public: |
|
33 enum matrix_type { |
|
34 Unknown = 0, |
|
35 Full, |
|
36 Diagonal, |
|
37 Permuted_Diagonal, |
|
38 Upper, |
|
39 Lower, |
|
40 Permuted_Upper, |
|
41 Permuted_Lower, |
|
42 Banded, |
|
43 Hermitian, |
|
44 Banded_Hermitian, |
|
45 Tridiagonal, |
|
46 Tridiagonal_Hermitian, |
|
47 Rectangular |
|
48 }; |
|
49 |
5322
|
50 SparseType (void); |
5164
|
51 |
|
52 SparseType (const SparseType &a); |
|
53 |
|
54 SparseType (const SparseMatrix &a); |
|
55 |
|
56 SparseType (const SparseComplexMatrix &a); |
|
57 |
5322
|
58 SparseType (const matrix_type t); |
|
59 |
|
60 SparseType (const matrix_type t, const octave_idx_type np, |
|
61 const octave_idx_type *p); |
|
62 |
|
63 SparseType (const matrix_type t, const octave_idx_type ku, |
|
64 const octave_idx_type kl); |
|
65 |
5164
|
66 ~SparseType (void); |
|
67 |
|
68 SparseType& operator = (const SparseType& a); |
|
69 |
5322
|
70 int type (bool quiet = true); |
5164
|
71 |
|
72 int type (const SparseMatrix &a); |
|
73 |
|
74 int type (const SparseComplexMatrix &a); |
|
75 |
|
76 double band_density (void) const { return bandden; } |
|
77 |
|
78 int nupper (void) const { return upper_band; } |
|
79 |
|
80 int nlower (void) const { return lower_band; } |
|
81 |
|
82 bool is_dense (void) const { return dense; } |
|
83 |
|
84 bool is_diagonal (void) const |
|
85 { return (typ == Diagonal || typ == Permuted_Diagonal); } |
|
86 |
|
87 bool is_upper_triangular (void) const |
|
88 { return (typ == Upper || typ == Permuted_Upper); } |
|
89 |
|
90 bool is_lower_triangular (void) const |
|
91 { return (typ == Lower || typ == Permuted_Lower); } |
|
92 |
|
93 bool is_banded (void) |
|
94 { return (typ == Banded || typ == Banded_Hermitian); } |
|
95 |
|
96 bool is_tridiagonal (void) const |
|
97 { return (typ == Tridiagonal || typ == Tridiagonal_Hermitian); } |
|
98 |
|
99 bool is_hermitian (void) const |
|
100 { return (typ == Banded_Hermitian || typ == Tridiagonal_Hermitian || |
|
101 typ == Hermitian); } |
|
102 |
|
103 bool is_rectangular (void) const { return (typ == Rectangular); } |
|
104 |
|
105 bool is_known (void) const { return (typ != Unknown); } |
|
106 |
|
107 bool is_unknown (void) const { return (typ == Unknown); } |
|
108 |
|
109 void info (void) const; |
|
110 |
5322
|
111 octave_idx_type * triangular_perm (void) const { return perm; } |
5164
|
112 |
5322
|
113 void invalidate_type (void) { typ = Unknown; } |
5164
|
114 |
|
115 void mark_as_diagonal (void) { typ = Diagonal; } |
|
116 |
5322
|
117 void mark_as_permuted_diagonal (void) { typ = Permuted_Diagonal; } |
|
118 |
5164
|
119 void mark_as_upper_triangular (void) { typ = Upper; } |
|
120 |
|
121 void mark_as_lower_triangular (void) { typ = Lower; } |
|
122 |
|
123 void mark_as_tridiagonal (void) {typ = Tridiagonal; } |
|
124 |
5275
|
125 void mark_as_banded (const octave_idx_type ku, const octave_idx_type kl) |
5164
|
126 { typ = Banded; upper_band = ku; lower_band = kl; } |
|
127 |
|
128 void mark_as_full (void) { typ = Full; } |
|
129 |
|
130 void mark_as_rectangular (void) { typ = Rectangular; } |
|
131 |
|
132 void mark_as_dense (void) { dense = true; } |
|
133 |
|
134 void mark_as_not_dense (void) { dense = false; } |
|
135 |
|
136 void mark_as_symmetric (void); |
|
137 |
|
138 void mark_as_unsymmetric (void); |
|
139 |
5322
|
140 void mark_as_permuted (const octave_idx_type np, const octave_idx_type *p); |
5164
|
141 |
|
142 void mark_as_unpermuted (void); |
|
143 |
5282
|
144 SparseType transpose (void) const; |
|
145 |
5164
|
146 private: |
|
147 void type (int new_typ) { typ = static_cast<matrix_type>(new_typ); } |
|
148 |
|
149 matrix_type typ; |
|
150 double sp_bandden; |
|
151 double bandden; |
5275
|
152 octave_idx_type upper_band; |
|
153 octave_idx_type lower_band; |
5164
|
154 bool dense; |
5275
|
155 octave_idx_type nperm; |
5322
|
156 octave_idx_type *perm; |
5164
|
157 }; |
|
158 |
|
159 #endif |
|
160 |
|
161 /* |
|
162 ;;; Local Variables: *** |
|
163 ;;; mode: C++ *** |
|
164 ;;; End: *** |
|
165 */ |