GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
boolNDArray.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2003-2021 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 (octave_boolNDArray_h)
27 #define octave_boolNDArray_h 1
28 
29 #include "octave-config.h"
30 
31 #include "Array.h"
32 #include "bsxfun-decl.h"
33 #include "mx-defs.h"
34 #include "mx-op-decl.h"
35 
36 class
37 OCTAVE_API
38 boolNDArray : public Array<bool>
39 {
40 public:
41 
43 
44  boolNDArray (void) : Array<bool> () { }
45 
46  boolNDArray (const dim_vector& dv) : Array<bool> (dv) { }
47 
48  boolNDArray (const dim_vector& dv, const bool& val)
49  : Array<bool> (dv, val) { }
50 
51  boolNDArray (const boolNDArray& a) : Array<bool> (a) { }
52 
53  boolNDArray (const Array<bool>& a) : Array<bool> (a) { }
54 
55  boolNDArray& operator = (const boolNDArray& a)
56  {
58  return *this;
59  }
60 
61  // unary operations
62 
63  boolNDArray operator ! (void) const;
64 
65  boolNDArray& invert (void);
66 
67  bool any_element_is_nan (void) const { return false; }
68 
69  // FIXME: this is not quite the right thing.
70 
71  boolNDArray all (int dim = -1) const;
72  boolNDArray any (int dim = -1) const;
73 
74  boolNDArray concat (const boolNDArray& rb,
76 
77  boolNDArray& insert (const boolNDArray& a, octave_idx_type r,
78  octave_idx_type c);
79  boolNDArray& insert (const boolNDArray& a,
81 
82  boolNDArray squeeze (void) const { return Array<bool>::squeeze (); }
83 
85  const dim_vector& dimensions,
86  int start_dimension = 0);
87 
89  const dim_vector& dimensions);
90 
91  // i/o
92 
93  // friend std::ostream& operator << (std::ostream& os, const NDArray& a);
94  // friend std::istream& operator >> (std::istream& is, NDArray& a);
95 
96  // bool all_elements_are_real (void) const;
97  // bool all_integers (double& max_val, double& min_val) const;
98 
99  boolNDArray diag (octave_idx_type k = 0) const;
100 
102 };
103 
106 
107 NDS_BOOL_OP_DECLS (boolNDArray, bool, OCTAVE_API)
108 NDS_CMP_OP_DECLS (boolNDArray, bool, OCTAVE_API)
109 
110 SND_BOOL_OP_DECLS (bool, boolNDArray, OCTAVE_API)
111 SND_CMP_OP_DECLS (bool, boolNDArray, OCTAVE_API)
112 
113 extern OCTAVE_API boolNDArray&
115 extern OCTAVE_API boolNDArray&
117 
118 BSXFUN_OP_DECL (and, boolNDArray, OCTAVE_API);
119 BSXFUN_OP_DECL (or, boolNDArray, OCTAVE_API);
120 
121 #endif
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:177
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:60
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:418
OCTAVE_API boolNDArray & mx_el_and_assign(boolNDArray &m, const boolNDArray &a)
Definition: boolNDArray.cc:132
OCTAVE_API boolNDArray & mx_el_or_assign(boolNDArray &m, const boolNDArray &a)
Definition: boolNDArray.cc:144
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:29
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Definition: Array.cc:117
Array< T > & operator=(const Array< T > &a)
Definition: Array.h:325
boolNDArray(const boolNDArray &a)
Definition: boolNDArray.h:51
boolNDArray squeeze(void) const
Definition: boolNDArray.h:82
boolNDArray(const dim_vector &dv)
Definition: boolNDArray.h:46
boolNDArray(const dim_vector &dv, const bool &val)
Definition: boolNDArray.h:48
bool any_element_is_nan(void) const
Definition: boolNDArray.h:67
boolNDArray(const Array< bool > &a)
Definition: boolNDArray.h:53
boolMatrix matrix_type
Definition: boolNDArray.h:42
boolNDArray(void)
Definition: boolNDArray.h:44
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753
T * r
Definition: mx-inlines.cc:773
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:227
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:219
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:173
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:192
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:165
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:200
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value operator!(const octave_value &a)
Definition: ov.h:1536