comparison liboctave/boolSparse.h @ 5164:57077d0ddc8e

[project @ 2005-02-25 19:55:24 by jwe]
author jwe
date Fri, 25 Feb 2005 19:55:28 +0000
parents
children 23b37da9fd5b
comparison
equal deleted inserted replaced
5163:9f3299378193 5164:57077d0ddc8e
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
17 along with this program; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 */
21
22 #if !defined (octave_boolSparse_h)
23 #define octave_boolSparse_h 1
24
25 #include "Sparse.h"
26 #include "MSparse-defs.h"
27 #include "Sparse-op-defs.h"
28
29 class
30 SparseBoolMatrix : public Sparse<bool>
31 {
32 public:
33
34 SparseBoolMatrix (void) : Sparse<bool> () { }
35
36 SparseBoolMatrix (int r, int c) : Sparse<bool> (r, c) { }
37
38 explicit SparseBoolMatrix (int r, int c, bool val)
39 : Sparse<bool> (r, c, val) { }
40
41 SparseBoolMatrix (const Sparse<bool>& a) : Sparse<bool> (a) { }
42
43 SparseBoolMatrix (const SparseBoolMatrix& a) : Sparse<bool> (a) { }
44
45 SparseBoolMatrix (const SparseBoolMatrix& a, const dim_vector& dv)
46 : Sparse<bool> (a, dv) { }
47
48 explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { }
49
50 explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { }
51
52 explicit SparseBoolMatrix (const Array<bool> a, const Array<int>& r,
53 const Array<int>& c, int nr = -1,
54 int nc = -1, bool sum_terms = true)
55 : Sparse<bool> (a, r, c, nr, nc, sum_terms) { }
56
57 explicit SparseBoolMatrix (const Array<bool> a, const Array<double>& r,
58 const Array<double>& c, int nr = -1,
59 int nc = -1, bool sum_terms = true)
60 : Sparse<bool> (a, r, c, nr, nc, sum_terms) { }
61
62 SparseBoolMatrix (int r, int c, int num_nz) : Sparse<bool> (r, c, num_nz) { }
63
64 SparseBoolMatrix& operator = (const SparseBoolMatrix& a)
65 {
66 Sparse<bool>::operator = (a);
67 return *this;
68 }
69
70 bool operator == (const SparseBoolMatrix& a) const;
71 bool operator != (const SparseBoolMatrix& a) const;
72
73 SparseBoolMatrix transpose (void) const
74 { return Sparse<bool>::transpose (); }
75
76 // destructive insert/delete/reorder operations
77
78 SparseBoolMatrix& insert (const SparseBoolMatrix& a, int r, int c);
79
80 SparseBoolMatrix concat (const SparseBoolMatrix& rb,
81 const Array<int>& ra_idx);
82
83 boolMatrix matrix_value (void) const;
84
85 SparseBoolMatrix squeeze (void) const;
86
87 SparseBoolMatrix index (idx_vector& i, int resize_ok) const;
88
89 SparseBoolMatrix index (idx_vector& i, idx_vector& j, int resize_ok) const;
90
91 SparseBoolMatrix index (Array<idx_vector>& ra_idx, int resize_ok) const;
92
93 SparseBoolMatrix reshape (const dim_vector& new_dims) const;
94
95 SparseBoolMatrix permute (const Array<int>& vec, bool inv = false) const;
96
97 SparseBoolMatrix ipermute (const Array<int>& vec) const;
98
99 // unary operations
100
101 SparseBoolMatrix operator ! (void) const;
102
103 // other operations
104
105 SparseBoolMatrix all (int dim = -1) const;
106 SparseBoolMatrix any (int dim = -1) const;
107
108 // i/o
109
110 friend std::ostream& operator << (std::ostream& os, const SparseBoolMatrix& a);
111 friend std::istream& operator >> (std::istream& is, SparseBoolMatrix& a);
112 };
113
114 SPARSE_SMS_EQNE_OP_DECLS (SparseBoolMatrix, bool)
115 SPARSE_SMS_BOOL_OP_DECLS (SparseBoolMatrix, bool)
116
117 SPARSE_SSM_EQNE_OP_DECLS (bool, SparseBoolMatrix)
118 SPARSE_SSM_BOOL_OP_DECLS (bool, SparseBoolMatrix)
119
120 SPARSE_SMSM_EQNE_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix)
121 SPARSE_SMSM_BOOL_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix)
122
123 #endif
124
125 /*
126 ;;; Local Variables: ***
127 ;;; mode: C++ ***
128 ;;; End: ***
129 */