annotate liboctave/array/boolSparse.cc @ 19461:65554f5847ac

don't include oct-locbuf.h in header files unnecessarily * oct-stream.h: Don't include oct-locbuf.h. * Sparse-op-decls.h: New file. * module.mk (OPERATORS_INC): Include it in the list. * Sparse-op-defs.h: Move decls to Sparse-op-decls.h. * CSparse.h, boolSparse.h, dSparse.h: Include Sparse-op-decls.h instead of Sparse-op-defs.h. * help.cc, oct-map.cc, oct-stream.cc, quadcc.cc, strfind.cc, sub2ind.cc, utils.cc, xpow.cc, __delaunayn__.cc, __ichol__.cc, __ilu__.cc, __voronoi__.cc, convhulln.cc, ov-base-mat.cc, op-dm-scm.cc, op-dm-template.cc, op-fcm-fs.cc, op-fcs-fm.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-pm-template.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, pt-mat.cc, CMatrix.cc, CNDArray.cc, CSparse.cc, MatrixType.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc, dMatrix.cc, dSparse.cc, fCMatrix.cc, fCNDArray.cc, fMatrix.cc, eigs-base.cc, oct-norm.cc, sparse-base-lu.cc, * mx-op-defs.h: Update list of include files accordingly. * sparse-mk-ops.awk: Update emitted list of include files accordingly.
author John W. Eaton <jwe@octave.org>
date Sun, 19 Oct 2014 08:42:58 -0400
parents 8e056300994b
children af41e41ad28e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
1 /*
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
3 Copyright (C) 2004-2013 David Bateman
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11287
diff changeset
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
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6823
diff changeset
6
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6823
diff changeset
7 This file is part of Octave.
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
8
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6823
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6823
diff changeset
12 option) any later version.
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
13
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
17 for more details.
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
18
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6823
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6823
diff changeset
21 <http://www.gnu.org/licenses/>.
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
22
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
23 */
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
24
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
26 #include <config.h>
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
27 #endif
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
28
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
29 #include <iostream>
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
30 #include <vector>
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
31
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
32 #include "quit.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
33 #include "lo-ieee.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
34 #include "lo-mappers.h"
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
35
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
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-mem.h"
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
39 #include "oct-locbuf.h"
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
40
19461
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 18084
diff changeset
41 #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
42
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
43 // SparseBoolMatrix class.
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
44
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
45 bool
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
46 SparseBoolMatrix::operator == (const SparseBoolMatrix& a) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
47 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
48 octave_idx_type nr = rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
49 octave_idx_type nc = cols ();
10506
bdf5d85cfc5e replace nzmax by nnz where appropriate in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10421
diff changeset
50 octave_idx_type nz = nnz ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
51 octave_idx_type nr_a = a.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
52 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
53 octave_idx_type nz_a = a.nnz ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
54
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
55 if (nr != nr_a || nc != nc_a || nz != nz_a)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
56 return false;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
57
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
58 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
59 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
60 return false;
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
61
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
62 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
63 if (data (i) != a.data (i) || ridx (i) != a.ridx (i))
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
64 return false;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
65
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
66 return true;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
67 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
68
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
69 bool
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
70 SparseBoolMatrix::operator != (const SparseBoolMatrix& a) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
71 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
72 return !(*this == a);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
73 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
74
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
75 SparseBoolMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
76 SparseBoolMatrix::insert (const SparseBoolMatrix& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
77 octave_idx_type r, octave_idx_type c)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
78 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
79 Sparse<bool>::insert (a, r, c);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
80 return *this;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
81 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
82
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents: 6217
diff changeset
83 SparseBoolMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
84 SparseBoolMatrix::insert (const SparseBoolMatrix& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
85 const Array<octave_idx_type>& indx)
6823
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents: 6217
diff changeset
86 {
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents: 6217
diff changeset
87 Sparse<bool>::insert (a, indx);
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents: 6217
diff changeset
88 return *this;
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents: 6217
diff changeset
89 }
9fddcc586065 [project @ 2007-08-24 08:27:27 by dbateman]
dbateman
parents: 6217
diff changeset
90
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
91 SparseBoolMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
92 SparseBoolMatrix::concat (const SparseBoolMatrix& rb,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
93 const Array<octave_idx_type>& ra_idx)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
94 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
95 // Don't use numel to avoid all possiblity of an overflow
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
96 if (rb.rows () > 0 && rb.cols () > 0)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
97 insert (rb, ra_idx(0), ra_idx(1));
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
98 return *this;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
99 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
100
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
101 // unary operations
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
102
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
103 SparseBoolMatrix
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
104 SparseBoolMatrix::operator ! (void) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
105 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
106 octave_idx_type nr = rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
107 octave_idx_type nc = cols ();
10506
bdf5d85cfc5e replace nzmax by nnz where appropriate in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 10421
diff changeset
108 octave_idx_type nz1 = nnz ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
109 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
110
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
111 SparseBoolMatrix r (nr, nc, nz2);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
112
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
113 octave_idx_type ii = 0;
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
114 octave_idx_type jj = 0;
6217
95084cd8723c [project @ 2006-12-22 17:51:28 by jwe]
jwe
parents: 5775
diff changeset
115 r.cidx (0) = 0;
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
116 for (octave_idx_type i = 0; i < nc; i++)
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
117 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
118 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
119 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14138
diff changeset
120 if (jj < cidx (i+1) && ridx (jj) == j)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
121 jj++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
122 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
123 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14138
diff changeset
124 r.data (ii) = true;
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14138
diff changeset
125 r.ridx (ii++) = j;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
126 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
127 }
6217
95084cd8723c [project @ 2006-12-22 17:51:28 by jwe]
jwe
parents: 5775
diff changeset
128 r.cidx (i+1) = ii;
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
129 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
130
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
131 return r;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
132 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
133
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
134 // other operations
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
135
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
136 // FIXME: Do these really belong here? Maybe they should be in a base class?
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
137
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
138 SparseBoolMatrix
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
139 SparseBoolMatrix::all (int dim) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
140 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
141 SPARSE_ALL_OP (dim);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
142 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
143
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
144 SparseBoolMatrix
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
145 SparseBoolMatrix::any (int dim) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
146 {
10976
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
147 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
148 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
149 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
150 octave_idx_type nz = nnz ();
10976
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
151 if (dim == -1)
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
152 dim = (nr == 1 && nc != 1) ? 1 : 0;
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
153
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
154 if (dim == 0)
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
155 {
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
156 // Result is a row vector.
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
157 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
158 retval.xcidx (0) = 0;
11571
0e414f837c58 Fix indexing error in the construction of sparse matrices
David Bateman <dbateman@free.fr>
parents: 11570
diff changeset
159 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
160 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
161 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
162 retval.change_capacity (new_nz);
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
163 fill_or_memset (new_nz, static_cast<octave_idx_type> (0), retval.ridx ());
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
164 fill_or_memset (new_nz, true, retval.data ());
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
165 }
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
166 else if (dim == 1)
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
167 {
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
168 // Result is a column vector.
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
169 if (nz > nr/4)
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
170 {
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
171 // 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
172 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
173 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
174 tmp.xelem (ridx (i)) = true;
10976
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
175 retval = tmp;
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
176 }
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
177 else
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
178 {
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
179 Array<octave_idx_type> tmp (dim_vector (nz, 1));
10983
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
180 copy_or_memcpy (nz, ridx (), tmp.fortran_vec ());
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
181 retval = Sparse<bool> (Array<bool> (dim_vector (1, 1), true),
11287
d81b79c1bd5d fixes for --enable-64
John W. Eaton <jwe@octave.org>
parents: 10983
diff changeset
182 idx_vector (tmp),
d81b79c1bd5d fixes for --enable-64
John W. Eaton <jwe@octave.org>
parents: 10983
diff changeset
183 idx_vector (static_cast<octave_idx_type> (0)),
d81b79c1bd5d fixes for --enable-64
John W. Eaton <jwe@octave.org>
parents: 10983
diff changeset
184 nr, 1, false);
10983
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
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
188 return retval;
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
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
191 SparseMatrix
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
192 SparseBoolMatrix::sum (int dim) const
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
193 {
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
194 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
195 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
196 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
197 octave_idx_type nz = nnz ();
10983
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
198 if (dim == -1)
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
199 dim = (nr == 1 && nc != 1) ? 1 : 0;
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
200
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
201 if (dim == 0)
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
202 {
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
203 // Result is a row vector.
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
204 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
205 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
206 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
207 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
208 retval.change_capacity (new_nz);
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
209 fill_or_memset (new_nz, static_cast<octave_idx_type> (0), retval.ridx ());
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14138
diff changeset
210 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
211 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14138
diff changeset
212 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
213 if (c > 0)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14138
diff changeset
214 retval.xdata (k++) = c;
10983
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 }
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
217 else if (dim == 1)
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
218 {
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
219 // Result is a column vector.
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
220 if (nz > nr)
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
221 {
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
222 // 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
223 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
224 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
225 tmp.xelem (ridx (i)) += 1.0;
10983
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
226 retval = tmp;
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
227 }
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
228 else
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
229 {
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
230 Array<octave_idx_type> tmp (dim_vector (nz, 1));
10983
4b51c0a20a98 optimize sum of sparse logical matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10976
diff changeset
231 copy_or_memcpy (nz, ridx (), tmp.fortran_vec ());
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
232 retval = Sparse<double> (Array<double> (dim_vector (1, 1), 1.0),
11287
d81b79c1bd5d fixes for --enable-64
John W. Eaton <jwe@octave.org>
parents: 10983
diff changeset
233 idx_vector (tmp),
d81b79c1bd5d fixes for --enable-64
John W. Eaton <jwe@octave.org>
parents: 10983
diff changeset
234 idx_vector (static_cast<octave_idx_type> (0)),
d81b79c1bd5d fixes for --enable-64
John W. Eaton <jwe@octave.org>
parents: 10983
diff changeset
235 nr, 1);
10976
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
80653e42a551 optimize any for sparse bool matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
239 return retval;
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
240 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
241
7515
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
242 SparseBoolMatrix
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
243 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
244 {
7620
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7515
diff changeset
245 return Sparse<bool>::diag (k);
7515
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
246 }
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
247
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
248 boolMatrix
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
249 SparseBoolMatrix::matrix_value (void) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
250 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
251 octave_idx_type nr = rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
252 octave_idx_type nc = cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
253
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
254 boolMatrix retval (nr, nc, false);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
255 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
256 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
257 retval.elem (ridx (i), j) = data (i);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
258
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
259 return retval;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
260 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
261
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
262 std::ostream&
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
263 operator << (std::ostream& os, const SparseBoolMatrix& a)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
264 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
265 octave_idx_type nc = a.cols ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
266
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
267 // 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
268 // 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
269 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
270 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
271 octave_quit ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
272 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
273 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
274 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
275
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
276 return os;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
277 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
278
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
279 std::istream&
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
280 operator >> (std::istream& is, SparseBoolMatrix& a)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
281 {
9469
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8999
diff changeset
282 typedef SparseBoolMatrix::element_type elt_type;
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
283
9469
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8999
diff changeset
284 return read_sparse_matrix<elt_type> (is, a, octave_read_value<bool>);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
285 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
286
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
287 SparseBoolMatrix
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
288 SparseBoolMatrix::squeeze (void) const
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
289 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
290 return Sparse<bool>::squeeze ();
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
291 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
292
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
293 SparseBoolMatrix
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
294 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
295 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
296 return Sparse<bool>::index (i, resize_ok);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
297 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
298
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
299 SparseBoolMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
300 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
301 bool resize_ok) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
302 {
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
303 return Sparse<bool>::index (i, j, resize_ok);
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
304 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11571
diff changeset
305
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
306 SparseBoolMatrix
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
307 SparseBoolMatrix::reshape (const dim_vector& new_dims) const
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
308 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
309 return Sparse<bool>::reshape (new_dims);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
310 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
311
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
312 SparseBoolMatrix
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
313 SparseBoolMatrix::permute (const Array<octave_idx_type>& vec, bool inv) const
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
314 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
315 return Sparse<bool>::permute (vec, inv);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
316 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
317
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
318 SparseBoolMatrix
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
319 SparseBoolMatrix::ipermute (const Array<octave_idx_type>& vec) const
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
320 {
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
321 return Sparse<bool>::ipermute (vec);
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
322 }
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
323
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
324 SPARSE_SMS_EQNE_OPS (SparseBoolMatrix, false, , bool, false, )
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
325 SPARSE_SMS_BOOL_OPS (SparseBoolMatrix, bool, false)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
326
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
327 SPARSE_SSM_EQNE_OPS (bool, false, , SparseBoolMatrix, false, )
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
328 SPARSE_SSM_BOOL_OPS (bool, SparseBoolMatrix, false)
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
329
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
330 SPARSE_SMSM_EQNE_OPS (SparseBoolMatrix, false, , SparseBoolMatrix, false, )
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents:
diff changeset
331 SPARSE_SMSM_BOOL_OPS (SparseBoolMatrix, SparseBoolMatrix, false)