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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
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
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
28 #endif
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
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
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
31
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4543
diff changeset
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
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
34 #include "lo-error.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
35 #include "str-vec.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
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
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
38
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
39 // boolMatrix class.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
40
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
41 bool
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
42 boolMatrix::operator == (const boolMatrix& a) const
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
43 {
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
44 if (rows () != a.rows () || cols () != a.cols ())
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
45 return 0;
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
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
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
48 }
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
49
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
50 bool
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
51 boolMatrix::operator != (const boolMatrix& a) const
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
52 {
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
53 return !(*this == a);
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
54 }
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
55
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
56 boolMatrix&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
57 boolMatrix::insert (const boolMatrix& a, octave_idx_type r, octave_idx_type c)
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
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
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
60 return *this;
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
61 }
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
62
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
63 // unary operations
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
64
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
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
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
67 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
68 octave_idx_type nr = rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
69 octave_idx_type nc = cols ();
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
70
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
71 boolMatrix b (nr, nc);
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
72
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
73 for (octave_idx_type j = 0; j < nc; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
74 for (octave_idx_type i = 0; i < nr; i++)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
75 b.elem (i, j) = ! elem (i, j);
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
76
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
77 return b;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
78 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
79
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
80 // other operations
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
81
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
82 boolMatrix
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
83 boolMatrix::diag (octave_idx_type k) const
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
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
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
86 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
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)