GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
boolNDArray.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_boolNDArray_h)
24 #define octave_boolNDArray_h 1
25 
26 #include "Array.h"
27 
28 #include "mx-defs.h"
29 #include "mx-op-decl.h"
30 #include "bsxfun-decl.h"
31 
32 class
33 OCTAVE_API
34 boolNDArray : public Array<bool>
35 {
36 public:
37 
39 
40  boolNDArray (void) : Array<bool> () { }
41 
42  boolNDArray (const dim_vector& dv) : Array<bool> (dv) { }
43 
44  boolNDArray (const dim_vector& dv, const bool& val)
45  : Array<bool> (dv, val) { }
46 
47  boolNDArray (const boolNDArray& a) : Array<bool> (a) { }
48 
49  boolNDArray (const Array<bool>& a) : Array<bool> (a) { }
50 
51  boolNDArray& operator = (const boolNDArray& a)
52  {
54  return *this;
55  }
56 
57  // unary operations
58 
59  boolNDArray operator ! (void) const;
60 
61  boolNDArray& invert (void);
62 
63  bool any_element_is_nan (void) const { return false; }
64 
65  // FIXME: this is not quite the right thing.
66 
67  boolNDArray all (int dim = -1) const;
68  boolNDArray any (int dim = -1) const;
69 
70  NDArray sum (int dim = -1) const;
71  NDArray cumsum (int dim = -1) const;
72 
73  boolNDArray concat (const boolNDArray& rb,
75 
76  boolNDArray& insert (const boolNDArray& a, octave_idx_type r,
77  octave_idx_type c);
78  boolNDArray& insert (const boolNDArray& a,
80 
81  boolNDArray squeeze (void) const { return Array<bool>::squeeze (); }
82 
84  const dim_vector& dimensions,
85  int start_dimension = 0);
86 
88  const dim_vector& dimensions);
89 
90  // i/o
91 
92  // friend std::ostream& operator << (std::ostream& os, const NDArray& a);
93  // friend std::istream& operator >> (std::istream& is, NDArray& a);
94 
95  // bool all_elements_are_real (void) const;
96  // bool all_integers (double& max_val, double& min_val) const;
97 
98  boolNDArray diag (octave_idx_type k = 0) const;
99 
100  boolNDArray diag (octave_idx_type m, octave_idx_type n) const;
101 };
102 
104 NDND_CMP_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API)
105 
106 NDS_BOOL_OP_DECLS (boolNDArray, bool, OCTAVE_API)
107 NDS_CMP_OP_DECLS (boolNDArray, bool, OCTAVE_API)
108 
109 SND_BOOL_OP_DECLS (bool, boolNDArray, OCTAVE_API)
110 SND_CMP_OP_DECLS (bool, boolNDArray, OCTAVE_API)
111 
112 extern OCTAVE_API boolNDArray&
113 mx_el_and_assign (boolNDArray& m, const boolNDArray& a);
114 extern OCTAVE_API boolNDArray&
115 mx_el_or_assign (boolNDArray& m, const boolNDArray& a);
116 
117 BSXFUN_OP_DECL (and, boolNDArray, OCTAVE_API);
118 BSXFUN_OP_DECL (or, boolNDArray, OCTAVE_API);
119 
120 #endif
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:178
int bool
Definition: mex.h:56
boolNDArray(const dim_vector &dv)
Definition: boolNDArray.h:42
const octave_base_value const Array< octave_idx_type > & ra_idx
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:216
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:197
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:664
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:224
boolNDArray squeeze(void) const
Definition: boolNDArray.h:81
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:170
bool any_element_is_nan(void) const
Definition: boolNDArray.h:63
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:162
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:189
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:59
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Definition: Array.cc:114
boolMatrix matrix_type
Definition: boolNDArray.h:38
boolNDArray(void)
Definition: boolNDArray.h:40
OCTAVE_API boolNDArray & mx_el_and_assign(boolNDArray &m, const boolNDArray &a)
Definition: boolNDArray.cc:147
boolNDArray(const dim_vector &dv, const bool &val)
Definition: boolNDArray.h:44
boolNDArray(const Array< bool > &a)
Definition: boolNDArray.h:49
octave_value operator!(const octave_value &a)
Definition: ov.h:1293
boolNDArray(const boolNDArray &a)
Definition: boolNDArray.h:47
Array< T > & operator=(const Array< T > &a)
Definition: Array.h:226
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:27
OCTAVE_API boolNDArray & mx_el_or_assign(boolNDArray &m, const boolNDArray &a)
Definition: boolNDArray.cc:159