Mercurial > octave
annotate liboctave/array/boolMatrix.cc @ 33658:b1d6e40ac737 stable tip
NEWS.9.md: Fix typo and minor formatting changes.
* etc/NEWS.9.md: Fix typo. Adjust whitespace. Use markdown syntax for code
snippets.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 05 Jun 2024 11:27:35 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31771
diff
changeset
|
3 // Copyright (C) 1996-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2828 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
2828 | 28 #endif |
29 | |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
30 #include <ostream> |
2828 | 31 |
4669 | 32 #include "Array-util.h" |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
33 #include "boolMatrix.h" |
2828 | 34 #include "lo-error.h" |
35 #include "str-vec.h" | |
36 #include "mx-inlines.cc" | |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8743
diff
changeset
|
37 #include "mx-op-defs.h" |
2828 | 38 |
39 // boolMatrix class. | |
40 | |
41 bool | |
42 boolMatrix::operator == (const boolMatrix& a) const | |
43 { | |
44 if (rows () != a.rows () || cols () != a.cols ()) | |
45 return 0; | |
46 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
47 return mx_inline_equal (numel (), data (), a.data ()); |
2828 | 48 } |
49 | |
50 bool | |
51 boolMatrix::operator != (const boolMatrix& a) const | |
52 { | |
53 return !(*this == a); | |
54 } | |
55 | |
56 boolMatrix& | |
5275 | 57 boolMatrix::insert (const boolMatrix& a, octave_idx_type r, octave_idx_type c) |
2828 | 58 { |
10351
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
59 Array<bool>::insert (a, r, c); |
2828 | 60 return *this; |
61 } | |
62 | |
3203 | 63 // unary operations |
64 | |
65 boolMatrix | |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
66 boolMatrix::operator ! () const |
3203 | 67 { |
5275 | 68 octave_idx_type nr = rows (); |
69 octave_idx_type nc = cols (); | |
3203 | 70 |
71 boolMatrix b (nr, nc); | |
72 | |
5275 | 73 for (octave_idx_type j = 0; j < nc; j++) |
74 for (octave_idx_type i = 0; i < nr; i++) | |
3203 | 75 b.elem (i, j) = ! elem (i, j); |
76 | |
77 return b; | |
78 } | |
79 | |
80 // other operations | |
81 | |
6979 | 82 boolMatrix |
83 boolMatrix::diag (octave_idx_type k) const | |
84 { | |
10351
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
85 return Array<bool>::diag (k); |
6979 | 86 } |
87 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
88 MM_BOOL_OPS (boolMatrix, boolMatrix) |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
89 MS_BOOL_OPS (boolMatrix, bool) |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
90 SM_BOOL_OPS (bool, boolMatrix) |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
91 MM_CMP_OPS (boolMatrix, boolMatrix) |