GNU Octave  3.8.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-2013 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 #include "boolMatrix.h"
33 
34 
35 class
36 OCTAVE_API
37 boolNDArray : public Array<bool>
38 {
39 public:
40 
42 
43  boolNDArray (void) : Array<bool> () { }
44 
45  boolNDArray (const dim_vector& dv) : Array<bool> (dv) { }
46 
47  boolNDArray (const dim_vector& dv, const bool& val)
48  : Array<bool> (dv, val) { }
49 
50  boolNDArray (const boolNDArray& a) : Array<bool> (a) { }
51 
52  boolNDArray (const boolMatrix& a) : Array<bool> (a) { }
53 
54  boolNDArray (const Array<bool>& a) : Array<bool> (a) { }
55 
57  {
59  return *this;
60  }
61 
62  // unary operations
63 
64  boolNDArray operator ! (void) const;
65 
66  boolNDArray& invert (void);
67 
68  bool any_element_is_nan (void) const { return false; }
69 
70  // FIXME: this is not quite the right thing.
71 
72  boolNDArray all (int dim = -1) const;
73  boolNDArray any (int dim = -1) const;
74 
75  NDArray sum (int dim = -1) const;
76  NDArray cumsum (int dim = -1) const;
77 
78  boolNDArray concat (const boolNDArray& rb,
79  const Array<octave_idx_type>& ra_idx);
80 
81  boolNDArray& insert (const boolNDArray& a, octave_idx_type r,
82  octave_idx_type c);
83  boolNDArray& insert (const boolNDArray& a,
84  const Array<octave_idx_type>& ra_idx);
85 
86  boolMatrix matrix_value (void) const;
87 
88  boolNDArray squeeze (void) const { return Array<bool>::squeeze (); }
89 
90  static void increment_index (Array<octave_idx_type>& ra_idx,
91  const dim_vector& dimensions,
92  int start_dimension = 0);
93 
95  const dim_vector& dimensions);
96 
97  // i/o
98 
99  // friend std::ostream& operator << (std::ostream& os, const NDArray& a);
100  // friend std::istream& operator >> (std::istream& is, NDArray& a);
101 
102  // bool all_elements_are_real (void) const;
103  // bool all_integers (double& max_val, double& min_val) const;
104 
105  boolNDArray diag (octave_idx_type k = 0) const;
106 
107  boolNDArray diag (octave_idx_type m, octave_idx_type n) const;
108 };
109 
111 NDND_CMP_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API)
112 
113 NDS_BOOL_OP_DECLS (boolNDArray, bool, OCTAVE_API)
114 NDS_CMP_OP_DECLS (boolNDArray, bool, OCTAVE_API)
115 
116 SND_BOOL_OP_DECLS (bool, boolNDArray, OCTAVE_API)
117 SND_CMP_OP_DECLS (bool, boolNDArray, OCTAVE_API)
118 
119 extern OCTAVE_API boolNDArray&
120 mx_el_and_assign (boolNDArray& m, const boolNDArray& a);
121 extern OCTAVE_API boolNDArray&
122 mx_el_or_assign (boolNDArray& m, const boolNDArray& a);
123 
124 BSXFUN_OP_DECL (and, boolNDArray, OCTAVE_API);
125 BSXFUN_OP_DECL (or, boolNDArray, OCTAVE_API);
126 
127 #endif