GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
boolNDArray.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 "Array-util.h"
31#include "boolNDArray.h"
32#include "CNDArray.h"
33#include "mx-base.h"
34#include "lo-ieee.h"
35#include "mx-op-defs.h"
36
37#include "bsxfun-defs.cc"
38
39// unary operations
40
43{
44 return do_mx_unary_op<bool, bool> (*this, mx_inline_not);
45}
46
49{
50 if (is_shared ())
51 *this = ! *this;
52 else
53 do_mx_inplace_op<bool> (*this, mx_inline_not2);
54
55 return *this;
56}
57
58// FIXME: this is not quite the right thing.
59
61boolNDArray::all (int dim) const
62{
63 return do_mx_red_op<bool, bool> (*this, dim, mx_inline_all);
64}
65
67boolNDArray::any (int dim) const
68{
69 return do_mx_red_op<bool, bool> (*this, dim, mx_inline_any);
70}
71
75{
76 if (rb.numel () > 0)
77 insert (rb, ra_idx);
78 return *this;
79}
80
83{
84 Array<bool>::insert (a, r, c);
85 return *this;
86}
87
90{
92 return *this;
93}
94
95void
97 const dim_vector& dimensions,
98 int start_dimension)
99{
100 ::increment_index (ra_idx, dimensions, start_dimension);
101}
102
105 const dim_vector& dimensions)
106{
107 return ::compute_index (ra_idx, dimensions);
108}
109
112{
113 return Array<bool>::diag (k);
114}
115
118{
119 return Array<bool>::diag (m, n);
120}
121
124
127
130
133{
134 if (a.is_shared ())
135 a = mx_el_and (a, b);
136 else
137 do_mm_inplace_op<bool, bool> (a, b, mx_inline_and2, mx_inline_and2,
138 "operator &=");
139
140 return a;
141}
142
145{
146 if (a.is_shared ())
147 a = mx_el_or (a, b);
148 else
149 do_mm_inplace_op<bool, bool> (a, b, mx_inline_or2, mx_inline_or2,
150 "operator |=");
151
152 return a;
153}
154
boolNDArray & mx_el_or_assign(boolNDArray &a, const boolNDArray &b)
boolNDArray mx_el_and(const boolNDArray &m1, const boolNDArray &m2)
boolNDArray mx_el_or(const boolNDArray &m1, const boolNDArray &m2)
boolNDArray & mx_el_and_assign(boolNDArray &a, const boolNDArray &b)
#define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP)
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
Array< T, Alloc > & insert(const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
bool is_shared() const
Definition Array.h:676
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
boolNDArray any(int dim=-1) const
boolNDArray diag(octave_idx_type k=0) const
boolNDArray & invert()
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
boolNDArray & insert(const boolNDArray &a, octave_idx_type r, octave_idx_type c)
static void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
boolNDArray operator!() const
boolNDArray concat(const boolNDArray &rb, const Array< octave_idx_type > &ra_idx)
boolNDArray all(int dim=-1) const
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
bool mx_inline_any(const T *v, octave_idx_type n)
void mx_inline_or(std::size_t n, bool *r, const X *x, const Y *y)
void mx_inline_and2(std::size_t n, bool *r, const X *x)
void mx_inline_and(std::size_t n, bool *r, const X *x, const Y *y)
void mx_inline_not(std::size_t n, bool *r, const X *x)
bool mx_inline_all(const T *v, octave_idx_type n)
void mx_inline_or2(std::size_t n, bool *r, const X *x)
void mx_inline_not2(std::size_t n, bool *r)
#define NDND_BOOL_OPS(ND1, ND2)
Definition mx-op-defs.h:350
#define NDS_BOOL_OPS(ND, S)
Definition mx-op-defs.h:256
#define NDND_CMP_OPS(ND1, ND2)
Definition mx-op-defs.h:333
#define SND_BOOL_OPS(S, ND)
Definition mx-op-defs.h:303
#define NDS_CMP_OPS(ND, S)
Definition mx-op-defs.h:239
#define SND_CMP_OPS(S, ND)
Definition mx-op-defs.h:286
const octave_base_value const Array< octave_idx_type > & ra_idx