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_boolSparse_h) |
|
24 #define octave_boolSparse_h 1 |
|
25 |
|
26 #include "Sparse.h" |
|
27 #include "MSparse-defs.h" |
|
28 #include "Sparse-op-defs.h" |
|
29 |
|
30 class |
6108
|
31 OCTAVE_API |
5164
|
32 SparseBoolMatrix : public Sparse<bool> |
|
33 { |
|
34 public: |
|
35 |
|
36 SparseBoolMatrix (void) : Sparse<bool> () { } |
|
37 |
5275
|
38 SparseBoolMatrix (octave_idx_type r, octave_idx_type c) : Sparse<bool> (r, c) { } |
5164
|
39 |
5275
|
40 explicit SparseBoolMatrix (octave_idx_type r, octave_idx_type c, bool val) |
5164
|
41 : Sparse<bool> (r, c, val) { } |
|
42 |
|
43 SparseBoolMatrix (const Sparse<bool>& a) : Sparse<bool> (a) { } |
|
44 |
|
45 SparseBoolMatrix (const SparseBoolMatrix& a) : Sparse<bool> (a) { } |
|
46 |
|
47 SparseBoolMatrix (const SparseBoolMatrix& a, const dim_vector& dv) |
|
48 : Sparse<bool> (a, dv) { } |
|
49 |
|
50 explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { } |
|
51 |
|
52 explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { } |
|
53 |
5275
|
54 explicit SparseBoolMatrix (const Array<bool> a, const Array<octave_idx_type>& r, |
|
55 const Array<octave_idx_type>& c, octave_idx_type nr = -1, |
|
56 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
57 : Sparse<bool> (a, r, c, nr, nc, sum_terms) { } |
|
58 |
|
59 explicit SparseBoolMatrix (const Array<bool> a, const Array<double>& r, |
5275
|
60 const Array<double>& c, octave_idx_type nr = -1, |
|
61 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
62 : Sparse<bool> (a, r, c, nr, nc, sum_terms) { } |
|
63 |
5275
|
64 SparseBoolMatrix (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : Sparse<bool> (r, c, num_nz) { } |
5164
|
65 |
|
66 SparseBoolMatrix& operator = (const SparseBoolMatrix& a) |
|
67 { |
|
68 Sparse<bool>::operator = (a); |
|
69 return *this; |
|
70 } |
|
71 |
|
72 bool operator == (const SparseBoolMatrix& a) const; |
|
73 bool operator != (const SparseBoolMatrix& a) const; |
|
74 |
|
75 SparseBoolMatrix transpose (void) const |
|
76 { return Sparse<bool>::transpose (); } |
|
77 |
|
78 // destructive insert/delete/reorder operations |
|
79 |
5275
|
80 SparseBoolMatrix& insert (const SparseBoolMatrix& a, octave_idx_type r, octave_idx_type c); |
5164
|
81 |
|
82 SparseBoolMatrix concat (const SparseBoolMatrix& rb, |
5275
|
83 const Array<octave_idx_type>& ra_idx); |
5164
|
84 |
|
85 boolMatrix matrix_value (void) const; |
|
86 |
|
87 SparseBoolMatrix squeeze (void) const; |
|
88 |
|
89 SparseBoolMatrix index (idx_vector& i, int resize_ok) const; |
|
90 |
|
91 SparseBoolMatrix index (idx_vector& i, idx_vector& j, int resize_ok) const; |
|
92 |
|
93 SparseBoolMatrix index (Array<idx_vector>& ra_idx, int resize_ok) const; |
|
94 |
|
95 SparseBoolMatrix reshape (const dim_vector& new_dims) const; |
|
96 |
5275
|
97 SparseBoolMatrix permute (const Array<octave_idx_type>& vec, bool inv = false) const; |
5164
|
98 |
5275
|
99 SparseBoolMatrix ipermute (const Array<octave_idx_type>& vec) const; |
5164
|
100 |
|
101 // unary operations |
|
102 |
|
103 SparseBoolMatrix operator ! (void) const; |
|
104 |
|
105 // other operations |
|
106 |
|
107 SparseBoolMatrix all (int dim = -1) const; |
|
108 SparseBoolMatrix any (int dim = -1) const; |
|
109 |
|
110 // i/o |
|
111 |
6108
|
112 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const SparseBoolMatrix& a); |
|
113 friend OCTAVE_API std::istream& operator >> (std::istream& is, SparseBoolMatrix& a); |
5164
|
114 }; |
|
115 |
|
116 SPARSE_SMS_EQNE_OP_DECLS (SparseBoolMatrix, bool) |
|
117 SPARSE_SMS_BOOL_OP_DECLS (SparseBoolMatrix, bool) |
|
118 |
|
119 SPARSE_SSM_EQNE_OP_DECLS (bool, SparseBoolMatrix) |
|
120 SPARSE_SSM_BOOL_OP_DECLS (bool, SparseBoolMatrix) |
|
121 |
|
122 SPARSE_SMSM_EQNE_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix) |
|
123 SPARSE_SMSM_BOOL_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix) |
|
124 |
|
125 #endif |
|
126 |
|
127 /* |
|
128 ;;; Local Variables: *** |
|
129 ;;; mode: C++ *** |
|
130 ;;; End: *** |
|
131 */ |