Mercurial > octave
annotate liboctave/array/boolSparse.cc @ 21301:40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
* mk-octave-config-h.sh, mk-opts.pl, Backend.cc, BaseControl.cc,
ButtonControl.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc,
EditControl.cc, Figure.cc, FigureWindow.cc, GLCanvas.cc, KeyMap.cc,
ListBoxControl.cc, Logger.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc,
ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc,
PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc, RadioButtonControl.cc,
SliderControl.cc, TextControl.cc, TextEdit.cc, ToggleButtonControl.cc,
ToggleTool.cc, ToolBar.cc, ToolBarButton.cc, __init_qt__.cc,
annotation-dialog.cc, gl-select.cc, module.mk, kpty.cpp, color-picker.cc,
dialog.cc, documentation-dock-widget.cc, files-dock-widget.cc,
find-files-dialog.cc, find-files-model.cc, history-dock-widget.cc,
file-editor-tab.cc, file-editor-tab.h, file-editor.cc, find-dialog.cc,
marker.cc, octave-qscintilla.cc, octave-txt-lexer.cc, main-window.cc,
octave-cmd.cc, octave-dock-widget.cc, octave-gui.cc, octave-interpreter.cc,
octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc,
settings-dialog.cc, shortcut-manager.cc, terminal-dock-widget.cc,
thread-manager.cc, welcome-wizard.cc, workspace-model.cc, workspace-view.cc,
build-env-features.sh, build-env.in.cc, Cell.cc, __contourc__.cc,
__dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc,
__pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc, bitfcns.cc,
bsxfun.cc, c-file-ptr-stream.cc, cdisplay.c, cellfun.cc, coct-hdf5-types.c,
colloc.cc, comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
debug.cc, defaults.cc, defun.cc, det.cc, dirfns.cc, display.cc, dlmread.cc,
dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc, error.cc, errwarn.cc, event-queue.cc,
fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc,
gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc,
gl-render.cc, gl2ps-print.cc, graphics.cc, gripes.cc, hash.cc, help.cc,
hess.cc, hex2num.cc, hook-fcn.cc, input.cc, inv.cc, jit-ir.cc, jit-typeinfo.cc,
jit-util.cc, kron.cc, load-path.cc, load-save.cc, lookup.cc,
ls-ascii-helper.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc,
ls-oct-binary.cc, ls-oct-text.cc, ls-utils.cc, lsode.cc, lu.cc, luinc.cc,
mappers.cc, matrix_type.cc, max.cc, mex.cc, mgorth.cc, nproc.cc,
oct-errno.in.cc, oct-fstrm.cc, oct-hdf5-types.cc, oct-hist.cc, oct-iostrm.cc,
oct-lvalue.cc, oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc, oct-stream.cc,
oct-strstrm.cc, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, octave-link.cc,
ordschur.cc, pager.cc, pinv.cc, pr-output.cc, procstream.cc, profiler.cc,
psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc,
schur.cc, sighandlers.cc, siglist.c, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc,
spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc,
sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, text-renderer.cc, time.cc,
toplev.cc, tril.cc, tsearch.cc, txt-eng.cc, typecast.cc, urlwrite.cc, utils.cc,
variables.cc, xdiv.cc, xgl2ps.c, xnorm.cc, xpow.cc, zfstream.cc,
__delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc,
__init_fltk__.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc,
__voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc,
colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc,
mkbuiltins, mkops, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc,
ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc,
ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc,
ov-class.cc, ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.cc,
ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-fcn.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc,
ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc,
ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc,
ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc,
ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc,
ov-uint8.cc, ov-usr-fcn.cc, ov.cc, ovl.cc, octave.cc, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc,
op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc,
op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc,
op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc,
op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc,
op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc,
op-int-conv.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc,
op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc,
op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc,
op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc,
op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc,
op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc,
op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc,
op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, lex.ll, oct-parse.in.yy,
pt-arg-list.cc, pt-array-list.cc, pt-assign.cc, pt-binop.cc, pt-bp.cc,
pt-cbinop.cc, pt-cell.cc, pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc,
pt-const.cc, pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc,
pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc, pt-mat.cc,
pt-misc.cc, pt-pr-code.cc, pt-select.cc, pt-stmt.cc, pt-unop.cc, pt.cc,
token.cc, Array-jit.cc, Array-os.cc, Array-sym.cc, Array-tc.cc, version.cc,
Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc,
Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc,
Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc,
CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MArray-C.cc,
MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc,
MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MatrixType.cc, PermMatrix.cc,
Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, boolMatrix.cc,
boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc, dColVector.cc,
dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc,
dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc,
fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc,
fRowVector.cc, idx-vector.cc, int16NDArray.cc, int32NDArray.cc,
int64NDArray.cc, int8NDArray.cc, intNDArray.cc, uint16NDArray.cc,
uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc, blaswrap.c, cquit.c,
f77-extern.cc, f77-fcn.c, lo-error.c, quit.cc, CollocWt.cc, DASPK.cc, DASRT.cc,
DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, aepbalance.cc, chol.cc,
eigs-base.cc, fEIG.cc, gepbalance.cc, hess.cc, lo-mappers.cc, lo-specfun.cc,
lu.cc, oct-convn.cc, oct-fftw.cc, oct-norm.cc, oct-rand.cc, oct-spparms.cc,
qr.cc, qrp.cc, randgamma.c, randmtzig.c, randpoisson.c, schur.cc,
sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, svd.cc,
mk-ops.awk, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc,
oct-env.cc, oct-group.cc, oct-passwd.cc, oct-syscalls.cc, oct-time.cc,
oct-uname.cc, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c,
glob-match.cc, kpse.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c,
lo-ieee.cc, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc,
oct-inttypes.cc, oct-locbuf.cc, oct-mutex.cc, oct-rl-edit.c, oct-rl-hist.c,
oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc,
sparse-util.cc, str-vec.cc, unwind-prot.cc, url-transfer.cc,
display-available.c, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc,
octave-config.in.cc:
Use '#include "config.h"' rather than <config.h>.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 18 Feb 2016 13:34:50 -0800 |
parents | f7121e111991 |
children | aba2e6293dd8 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19381
diff
changeset
|
3 Copyright (C) 2004-2015 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10506
diff
changeset
|
5 Copyright (C) 2010 VZLU Prague |
7016 | 6 |
7 This file is part of Octave. | |
5164 | 8 |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
5164 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
5164 | 22 |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
26 # include "config.h" |
5164 | 27 #endif |
28 | |
29 #include <iostream> | |
30 #include <vector> | |
31 | |
32 #include "quit.h" | |
33 #include "lo-ieee.h" | |
34 #include "lo-mappers.h" | |
35 | |
36 #include "boolSparse.h" | |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
37 #include "dSparse.h" |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
38 #include "oct-locbuf.h" |
5164 | 39 |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
18084
diff
changeset
|
40 #include "Sparse-op-defs.h" |
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
18084
diff
changeset
|
41 |
5164 | 42 // SparseBoolMatrix class. |
43 | |
44 bool | |
45 SparseBoolMatrix::operator == (const SparseBoolMatrix& a) const | |
46 { | |
5275 | 47 octave_idx_type nr = rows (); |
48 octave_idx_type nc = cols (); | |
10506
bdf5d85cfc5e
replace nzmax by nnz where appropriate in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
49 octave_idx_type nz = nnz (); |
5275 | 50 octave_idx_type nr_a = a.rows (); |
51 octave_idx_type nc_a = a.cols (); | |
10506
bdf5d85cfc5e
replace nzmax by nnz where appropriate in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
52 octave_idx_type nz_a = a.nnz (); |
5164 | 53 |
54 if (nr != nr_a || nc != nc_a || nz != nz_a) | |
55 return false; | |
56 | |
5275 | 57 for (octave_idx_type i = 0; i < nc + 1; i++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
58 if (cidx (i) != a.cidx (i)) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
59 return false; |
5164 | 60 |
5275 | 61 for (octave_idx_type i = 0; i < nz; i++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
62 if (data (i) != a.data (i) || ridx (i) != a.ridx (i)) |
5164 | 63 return false; |
64 | |
65 return true; | |
66 } | |
67 | |
68 bool | |
69 SparseBoolMatrix::operator != (const SparseBoolMatrix& a) const | |
70 { | |
71 return !(*this == a); | |
72 } | |
73 | |
74 SparseBoolMatrix& | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
75 SparseBoolMatrix::insert (const SparseBoolMatrix& a, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 octave_idx_type r, octave_idx_type c) |
5164 | 77 { |
78 Sparse<bool>::insert (a, r, c); | |
79 return *this; | |
80 } | |
81 | |
6823 | 82 SparseBoolMatrix& |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 SparseBoolMatrix::insert (const SparseBoolMatrix& a, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 const Array<octave_idx_type>& indx) |
6823 | 85 { |
86 Sparse<bool>::insert (a, indx); | |
87 return *this; | |
88 } | |
89 | |
5164 | 90 SparseBoolMatrix |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
91 SparseBoolMatrix::concat (const SparseBoolMatrix& rb, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 const Array<octave_idx_type>& ra_idx) |
5164 | 93 { |
94 // Don't use numel to avoid all possiblity of an overflow | |
95 if (rb.rows () > 0 && rb.cols () > 0) | |
96 insert (rb, ra_idx(0), ra_idx(1)); | |
97 return *this; | |
98 } | |
99 | |
100 // unary operations | |
101 | |
102 SparseBoolMatrix | |
103 SparseBoolMatrix::operator ! (void) const | |
104 { | |
5275 | 105 octave_idx_type nr = rows (); |
106 octave_idx_type nc = cols (); | |
10506
bdf5d85cfc5e
replace nzmax by nnz where appropriate in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10421
diff
changeset
|
107 octave_idx_type nz1 = nnz (); |
5275 | 108 octave_idx_type nz2 = nr*nc - nz1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
109 |
5164 | 110 SparseBoolMatrix r (nr, nc, nz2); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
111 |
5275 | 112 octave_idx_type ii = 0; |
113 octave_idx_type jj = 0; | |
6217 | 114 r.cidx (0) = 0; |
5275 | 115 for (octave_idx_type i = 0; i < nc; i++) |
5164 | 116 { |
5275 | 117 for (octave_idx_type j = 0; j < nr; j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
118 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
119 if (jj < cidx (i+1) && ridx (jj) == j) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
120 jj++; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
121 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
122 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
123 r.data (ii) = true; |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
124 r.ridx (ii++) = j; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
125 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
126 } |
6217 | 127 r.cidx (i+1) = ii; |
5164 | 128 } |
129 | |
130 return r; | |
131 } | |
132 | |
133 // other operations | |
134 | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 // FIXME: Do these really belong here? Maybe they should be in a base class? |
5164 | 136 |
137 SparseBoolMatrix | |
138 SparseBoolMatrix::all (int dim) const | |
139 { | |
140 SPARSE_ALL_OP (dim); | |
141 } | |
142 | |
143 SparseBoolMatrix | |
144 SparseBoolMatrix::any (int dim) const | |
145 { | |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
146 Sparse<bool> retval; |
18084
8e056300994b
Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
147 octave_idx_type nr = rows (); |
8e056300994b
Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
148 octave_idx_type nc = cols (); |
8e056300994b
Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
149 octave_idx_type nz = nnz (); |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
150 if (dim == -1) |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
151 dim = (nr == 1 && nc != 1) ? 1 : 0; |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
152 |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
153 if (dim == 0) |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
154 { |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
155 // Result is a row vector. |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
156 retval = Sparse<bool> (1, nc); |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
157 retval.xcidx (0) = 0; |
11571
0e414f837c58
Fix indexing error in the construction of sparse matrices
David Bateman <dbateman@free.fr>
parents:
11570
diff
changeset
|
158 for (octave_idx_type i = 0; i < nc; i++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
159 retval.xcidx (i+1) = retval.xcidx (i) + (cidx (i+1) > cidx (i)); |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
160 octave_idx_type new_nz = retval.xcidx (nc); |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
161 retval.change_capacity (new_nz); |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19269
diff
changeset
|
162 std::fill_n (retval.ridx (), new_nz, static_cast<octave_idx_type> (0)); |
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19269
diff
changeset
|
163 std::fill_n (retval.data (), new_nz, true); |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
164 } |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
165 else if (dim == 1) |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
166 { |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
167 // Result is a column vector. |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
168 if (nz > nr/4) |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
169 { |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
170 // We can use O(nr) memory. |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
171 Array<bool> tmp (dim_vector (nr, 1), false); |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
172 for (octave_idx_type i = 0; i < nz; i++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
173 tmp.xelem (ridx (i)) = true; |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
174 retval = tmp; |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
175 } |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
176 else |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
177 { |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
178 Array<octave_idx_type> tmp (dim_vector (nz, 1)); |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19269
diff
changeset
|
179 std::copy (ridx (), ridx () + nz, tmp.fortran_vec ()); |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
180 retval = Sparse<bool> (Array<bool> (dim_vector (1, 1), true), |
11287 | 181 idx_vector (tmp), |
182 idx_vector (static_cast<octave_idx_type> (0)), | |
183 nr, 1, false); | |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
184 } |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
185 } |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
186 |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
187 return retval; |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
188 } |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
189 |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
190 SparseMatrix |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
191 SparseBoolMatrix::sum (int dim) const |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
192 { |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
193 Sparse<double> retval; |
18084
8e056300994b
Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
194 octave_idx_type nr = rows (); |
8e056300994b
Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
195 octave_idx_type nc = cols (); |
8e056300994b
Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
196 octave_idx_type nz = nnz (); |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
197 if (dim == -1) |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
198 dim = (nr == 1 && nc != 1) ? 1 : 0; |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
199 |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
200 if (dim == 0) |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
201 { |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
202 // Result is a row vector. |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
203 retval = Sparse<double> (1, nc); |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
204 for (octave_idx_type i = 0; i < nc; i++) |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
205 retval.xcidx (i+1) = retval.xcidx (i) + (cidx (i+1) > cidx (i)); |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
206 octave_idx_type new_nz = retval.xcidx (nc); |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
207 retval.change_capacity (new_nz); |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19269
diff
changeset
|
208 std::fill_n (retval.ridx (), new_nz, static_cast<octave_idx_type> (0)); |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
209 for (octave_idx_type i = 0, k = 0; i < nc; i++) |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
210 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
211 octave_idx_type c = cidx (i+1) - cidx (i); |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
212 if (c > 0) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
213 retval.xdata (k++) = c; |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
214 } |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
215 } |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
216 else if (dim == 1) |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
217 { |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
218 // Result is a column vector. |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
219 if (nz > nr) |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
220 { |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
221 // We can use O(nr) memory. |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
222 Array<double> tmp (dim_vector (nr, 1), 0); |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
223 for (octave_idx_type i = 0; i < nz; i++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
224 tmp.xelem (ridx (i)) += 1.0; |
10983
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
225 retval = tmp; |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
226 } |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
227 else |
4b51c0a20a98
optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10976
diff
changeset
|
228 { |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
229 Array<octave_idx_type> tmp (dim_vector (nz, 1)); |
19381
af41e41ad28e
replace oct-mem.h inline indirections by standard function calls.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19269
diff
changeset
|
230 std::copy (ridx (), ridx () + nz, tmp.fortran_vec ()); |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
231 retval = Sparse<double> (Array<double> (dim_vector (1, 1), 1.0), |
11287 | 232 idx_vector (tmp), |
233 idx_vector (static_cast<octave_idx_type> (0)), | |
234 nr, 1); | |
10976
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
235 } |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
236 } |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
237 |
80653e42a551
optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
238 return retval; |
5164 | 239 } |
240 | |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
241 SparseBoolMatrix |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
242 SparseBoolMatrix::diag (octave_idx_type k) const |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
243 { |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7515
diff
changeset
|
244 return Sparse<bool>::diag (k); |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
245 } |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
246 |
5164 | 247 boolMatrix |
248 SparseBoolMatrix::matrix_value (void) const | |
249 { | |
5275 | 250 octave_idx_type nr = rows (); |
251 octave_idx_type nc = cols (); | |
5164 | 252 |
253 boolMatrix retval (nr, nc, false); | |
5275 | 254 for (octave_idx_type j = 0; j < nc; j++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
255 for (octave_idx_type i = cidx (j); i < cidx (j+1); i++) |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
256 retval.elem (ridx (i), j) = data (i); |
5164 | 257 |
258 return retval; | |
259 } | |
260 | |
261 std::ostream& | |
262 operator << (std::ostream& os, const SparseBoolMatrix& a) | |
263 { | |
5275 | 264 octave_idx_type nc = a.cols (); |
5164 | 265 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
266 // add one to the printed indices to go from |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
267 // zero-based to one-based arrays |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
268 for (octave_idx_type j = 0; j < nc; j++) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
269 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
270 octave_quit (); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
271 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
272 os << a.ridx (i) + 1 << " " << j + 1 << " " << a.data (i) << "\n"; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
273 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
274 |
5164 | 275 return os; |
276 } | |
277 | |
278 std::istream& | |
279 operator >> (std::istream& is, SparseBoolMatrix& a) | |
280 { | |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8999
diff
changeset
|
281 typedef SparseBoolMatrix::element_type elt_type; |
5164 | 282 |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8999
diff
changeset
|
283 return read_sparse_matrix<elt_type> (is, a, octave_read_value<bool>); |
5164 | 284 } |
285 | |
286 SparseBoolMatrix | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
287 SparseBoolMatrix::squeeze (void) const |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
288 { |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
289 return Sparse<bool>::squeeze (); |
5164 | 290 } |
291 | |
292 SparseBoolMatrix | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
293 SparseBoolMatrix::index (const idx_vector& i, bool resize_ok) const |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
294 { |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
295 return Sparse<bool>::index (i, resize_ok); |
5164 | 296 } |
297 | |
298 SparseBoolMatrix | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
299 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
|
300 bool resize_ok) const |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
301 { |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
302 return Sparse<bool>::index (i, j, resize_ok); |
5164 | 303 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11571
diff
changeset
|
304 |
5164 | 305 SparseBoolMatrix |
306 SparseBoolMatrix::reshape (const dim_vector& new_dims) const | |
307 { | |
308 return Sparse<bool>::reshape (new_dims); | |
309 } | |
310 | |
311 SparseBoolMatrix | |
5275 | 312 SparseBoolMatrix::permute (const Array<octave_idx_type>& vec, bool inv) const |
5164 | 313 { |
314 return Sparse<bool>::permute (vec, inv); | |
315 } | |
316 | |
317 SparseBoolMatrix | |
5275 | 318 SparseBoolMatrix::ipermute (const Array<octave_idx_type>& vec) const |
5164 | 319 { |
320 return Sparse<bool>::ipermute (vec); | |
321 } | |
322 | |
323 SPARSE_SMS_EQNE_OPS (SparseBoolMatrix, false, , bool, false, ) | |
324 SPARSE_SMS_BOOL_OPS (SparseBoolMatrix, bool, false) | |
325 | |
326 SPARSE_SSM_EQNE_OPS (bool, false, , SparseBoolMatrix, false, ) | |
327 SPARSE_SSM_BOOL_OPS (bool, SparseBoolMatrix, false) | |
328 | |
329 SPARSE_SMSM_EQNE_OPS (SparseBoolMatrix, false, , SparseBoolMatrix, false, ) | |
330 SPARSE_SMSM_BOOL_OPS (SparseBoolMatrix, SparseBoolMatrix, false) |