GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
boolMatrix.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <ostream>
31
32#include "Array-util.h"
33#include "boolMatrix.h"
34#include "lo-error.h"
35#include "str-vec.h"
36#include "mx-inlines.cc"
37#include "mx-op-defs.h"
38
39// boolMatrix class.
40
41bool
43{
44 if (rows () != a.rows () || cols () != a.cols ())
45 return 0;
46
47 return mx_inline_equal (numel (), data (), a.data ());
48}
49
50bool
52{
53 return !(*this == a);
54}
55
58{
59 Array<bool>::insert (a, r, c);
60 return *this;
61}
62
63// unary operations
64
67{
68 octave_idx_type nr = rows ();
69 octave_idx_type nc = cols ();
70
71 boolMatrix b (nr, nc);
72
73 for (octave_idx_type j = 0; j < nc; j++)
74 for (octave_idx_type i = 0; i < nr; i++)
75 b.elem (i, j) = ! elem (i, j);
76
77 return b;
78}
79
80// other operations
81
84{
85 return Array<bool>::diag (k);
86}
87
T & elem(octave_idx_type n)
Size of the specified dimension.
Definition Array.h:563
octave_idx_type rows() const
Definition Array.h:463
Array< T, Alloc > & insert(const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
octave_idx_type cols() const
Definition Array.h:473
const bool * data() const
Definition Array.h:665
Array< T, Alloc > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
octave_idx_type numel() const
Number of elements in the array.
Definition Array.h:418
boolMatrix & insert(const boolMatrix &a, octave_idx_type r, octave_idx_type c)
Definition boolMatrix.cc:57
boolMatrix diag(octave_idx_type k=0) const
Definition boolMatrix.cc:83
bool operator==(const boolMatrix &a) const
Definition boolMatrix.cc:42
bool operator!=(const boolMatrix &a) const
Definition boolMatrix.cc:51
boolMatrix operator!() const
Definition boolMatrix.cc:66
bool mx_inline_equal(std::size_t n, const T1 *x, const T2 *y)
#define MM_BOOL_OPS(M1, M2)
Definition mx-op-defs.h:213
#define MM_CMP_OPS(M1, M2)
Definition mx-op-defs.h:196
#define SM_BOOL_OPS(S, M)
Definition mx-op-defs.h:170
#define MS_BOOL_OPS(M, S)
Definition mx-op-defs.h:127