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