Mercurial > octave
annotate liboctave/array/boolSparse.h @ 22323:bac0d6f07a3e
maint: Update copyright notices for 2016.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 17 Aug 2016 01:05:19 -0400 |
parents | 1473547f50f5 |
children | 4caa7b28d183 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
3 Copyright (C) 2004-2016 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5164 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5164 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5164 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20506
diff
changeset
|
24 #if ! defined (octave_boolSparse_h) |
5164 | 25 #define octave_boolSparse_h 1 |
26 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21175
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21175
diff
changeset
|
28 |
5164 | 29 #include "Sparse.h" |
20506
2aa4fb60ae77
MSparse code simplification by macro removal without reduction of functionality.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19697
diff
changeset
|
30 #include "MSparse.h" |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
31 |
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
32 #include "boolMatrix.h" |
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
33 #include "boolNDArray.h" |
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
34 #include "PermMatrix.h" |
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
35 |
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
36 #include "Sparse-op-decls.h" |
5164 | 37 |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10527
diff
changeset
|
38 class SparseMatrix; |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10527
diff
changeset
|
39 |
5164 | 40 class |
6108 | 41 OCTAVE_API |
5164 | 42 SparseBoolMatrix : public Sparse<bool> |
43 { | |
44 public: | |
45 | |
21175
f45f4f888db5
provide typedef for dense matrix type in sparse matrix classes
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
46 // Corresponding dense matrix type for this sparse matrix type. |
f45f4f888db5
provide typedef for dense matrix type in sparse matrix classes
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
47 typedef boolMatrix dense_matrix_type; |
f45f4f888db5
provide typedef for dense matrix type in sparse matrix classes
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
48 |
5164 | 49 SparseBoolMatrix (void) : Sparse<bool> () { } |
50 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
51 SparseBoolMatrix (octave_idx_type r, octave_idx_type c) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
52 : Sparse<bool> (r, c) { } |
5164 | 53 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
54 explicit SparseBoolMatrix (octave_idx_type r, octave_idx_type c, bool val) |
5164 | 55 : Sparse<bool> (r, c, val) { } |
56 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
57 SparseBoolMatrix (const dim_vector& dv, octave_idx_type nz = 0) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
58 : Sparse<bool> (dv, nz) { } |
6823 | 59 |
5164 | 60 SparseBoolMatrix (const Sparse<bool>& a) : Sparse<bool> (a) { } |
61 | |
62 SparseBoolMatrix (const SparseBoolMatrix& a) : Sparse<bool> (a) { } | |
63 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
64 SparseBoolMatrix (const SparseBoolMatrix& a, const dim_vector& dv) |
5164 | 65 : Sparse<bool> (a, dv) { } |
66 | |
67 explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { } | |
68 | |
69 explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { } | |
70 | |
13030
b646413c3d0e
Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11586
diff
changeset
|
71 explicit SparseBoolMatrix (const PermMatrix& a) : Sparse<bool> (a) { }; |
b646413c3d0e
Make operators do smarter sparse conversions on permutation matrices.
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11586
diff
changeset
|
72 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
73 SparseBoolMatrix (const Array<bool>& a, const idx_vector& r, |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
74 const idx_vector& c, octave_idx_type nr = -1, |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10480
diff
changeset
|
75 octave_idx_type nc = -1, bool sum_terms = true, |
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10480
diff
changeset
|
76 octave_idx_type nzm = -1) |
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10480
diff
changeset
|
77 : Sparse<bool> (a, r, c, nr, nc, sum_terms, nzm) { } |
10479
ded9beac7582
optimize sparse matrix assembly
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
78 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
79 SparseBoolMatrix (octave_idx_type r, octave_idx_type c, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
80 octave_idx_type num_nz) : Sparse<bool> (r, c, num_nz) { } |
5164 | 81 |
82 SparseBoolMatrix& operator = (const SparseBoolMatrix& a) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 Sparse<bool>::operator = (a); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
86 } |
5164 | 87 |
88 bool operator == (const SparseBoolMatrix& a) const; | |
89 bool operator != (const SparseBoolMatrix& a) const; | |
90 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
91 SparseBoolMatrix transpose (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 { return Sparse<bool>::transpose (); } |
5164 | 93 |
94 // destructive insert/delete/reorder operations | |
95 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 SparseBoolMatrix& insert (const SparseBoolMatrix& a, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
97 octave_idx_type r, octave_idx_type c); |
5164 | 98 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 SparseBoolMatrix& insert (const SparseBoolMatrix& a, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 const Array<octave_idx_type>& indx); |
6823 | 101 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
102 SparseBoolMatrix concat (const SparseBoolMatrix& rb, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
103 const Array<octave_idx_type>& ra_idx); |
5164 | 104 |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
105 SparseBoolMatrix diag (octave_idx_type k = 0) const; |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
106 |
5164 | 107 boolMatrix matrix_value (void) const; |
108 | |
109 SparseBoolMatrix squeeze (void) const; | |
110 | |
10421
99e9bae2d81e
improve sparse indexing interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
111 SparseBoolMatrix index (const idx_vector& i, bool resize_ok) const; |
5164 | 112 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 SparseBoolMatrix index (const idx_vector& i, const idx_vector& j, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 bool resize_ok) const; |
5164 | 115 |
116 SparseBoolMatrix reshape (const dim_vector& new_dims) const; | |
117 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
118 SparseBoolMatrix permute (const Array<octave_idx_type>& vec, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
119 bool inv = false) const; |
5164 | 120 |
5275 | 121 SparseBoolMatrix ipermute (const Array<octave_idx_type>& vec) const; |
5164 | 122 |
123 // unary operations | |
124 | |
125 SparseBoolMatrix operator ! (void) const; | |
126 | |
127 // other operations | |
128 | |
129 SparseBoolMatrix all (int dim = -1) const; | |
130 SparseBoolMatrix any (int dim = -1) const; | |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10527
diff
changeset
|
131 SparseMatrix sum (int dim = -1) const; |
5164 | 132 |
133 // i/o | |
134 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 friend OCTAVE_API std::ostream& operator << (std::ostream& os, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 const SparseBoolMatrix& a); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
137 friend OCTAVE_API std::istream& operator >> (std::istream& is, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 SparseBoolMatrix& a); |
5164 | 139 }; |
140 | |
6708 | 141 SPARSE_SMS_EQNE_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API) |
142 SPARSE_SMS_BOOL_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API) | |
5164 | 143 |
6708 | 144 SPARSE_SSM_EQNE_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API) |
145 SPARSE_SSM_BOOL_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API) | |
5164 | 146 |
6708 | 147 SPARSE_SMSM_EQNE_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API) |
148 SPARSE_SMSM_BOOL_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API) | |
5164 | 149 |
150 #endif |