4514
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 2003, 2004, 2005, 2006, 2007 John W. Eaton |
4514
|
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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
4514
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
4514
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_boolNDArray_h) |
|
24 #define octave_boolNDArray_h 1 |
|
25 |
|
26 #include "ArrayN.h" |
|
27 |
|
28 #include "mx-defs.h" |
|
29 #include "mx-op-defs.h" |
|
30 |
4650
|
31 #include "boolMatrix.h" |
|
32 |
4514
|
33 class |
6108
|
34 OCTAVE_API |
4514
|
35 boolNDArray : public ArrayN<bool> |
|
36 { |
|
37 public: |
5523
|
38 |
4514
|
39 boolNDArray (void) : ArrayN<bool> () { } |
|
40 |
4730
|
41 boolNDArray (const dim_vector& dv) : ArrayN<bool> (dv) { } |
4514
|
42 |
4730
|
43 boolNDArray (const dim_vector& dv, const bool& val) |
4587
|
44 : ArrayN<bool> (dv, val) { } |
4514
|
45 |
|
46 boolNDArray (const boolNDArray& a) : ArrayN<bool> (a) { } |
|
47 |
|
48 boolNDArray (const boolMatrix& a) : ArrayN<bool> (a) { } |
|
49 |
|
50 boolNDArray (const ArrayN<bool>& a) : ArrayN<bool> (a) { } |
|
51 |
|
52 boolNDArray& operator = (const boolNDArray& a) |
|
53 { |
|
54 ArrayN<bool>::operator = (a); |
|
55 return *this; |
|
56 } |
|
57 |
4543
|
58 // unary operations |
|
59 |
|
60 boolNDArray operator ! (void) const; |
|
61 |
5775
|
62 // FIXME -- this is not quite the right thing. |
4514
|
63 |
4556
|
64 boolNDArray all (int dim = -1) const; |
|
65 boolNDArray any (int dim = -1) const; |
4514
|
66 |
7113
|
67 boolNDArray sum (int dim = -1) const; |
|
68 |
5275
|
69 boolNDArray concat (const boolNDArray& rb, const Array<octave_idx_type>& ra_idx); |
4964
|
70 |
5275
|
71 boolNDArray& insert (const boolNDArray& a, octave_idx_type r, octave_idx_type c); |
|
72 boolNDArray& insert (const boolNDArray& a, const Array<octave_idx_type>& ra_idx); |
4964
|
73 |
4514
|
74 boolMatrix matrix_value (void) const; |
|
75 |
4532
|
76 boolNDArray squeeze (void) const { return ArrayN<bool>::squeeze (); } |
|
77 |
5275
|
78 static void increment_index (Array<octave_idx_type>& ra_idx, |
4532
|
79 const dim_vector& dimensions, |
|
80 int start_dimension = 0); |
|
81 |
5275
|
82 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx, |
4556
|
83 const dim_vector& dimensions); |
|
84 |
4514
|
85 // i/o |
|
86 |
|
87 // friend std::ostream& operator << (std::ostream& os, const NDArray& a); |
|
88 // friend std::istream& operator >> (std::istream& is, NDArray& a); |
|
89 |
|
90 static bool resize_fill_value (void) { return false; } |
|
91 |
|
92 // bool all_elements_are_real (void) const; |
|
93 // bool all_integers (double& max_val, double& min_val) const; |
|
94 |
5602
|
95 octave_idx_type nnz (void) const |
|
96 { |
|
97 octave_idx_type retval = 0; |
|
98 |
|
99 const bool *d = this->data (); |
|
100 |
|
101 octave_idx_type nel = this->numel (); |
|
102 |
|
103 for (octave_idx_type i = 0; i < nel; i++) |
|
104 { |
|
105 if (d[i]) |
|
106 retval++; |
|
107 } |
|
108 |
|
109 return retval; |
|
110 } |
|
111 |
4514
|
112 private: |
|
113 |
4587
|
114 boolNDArray (bool *d, dim_vector& dv) : ArrayN<bool> (d, dv) { } |
4514
|
115 }; |
|
116 |
6708
|
117 NDND_BOOL_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API) |
|
118 NDND_CMP_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API) |
4543
|
119 |
6708
|
120 NDS_BOOL_OP_DECLS (boolNDArray, bool, OCTAVE_API) |
|
121 NDS_CMP_OP_DECLS (boolNDArray, bool, OCTAVE_API) |
4669
|
122 |
6708
|
123 SND_BOOL_OP_DECLS (bool, boolNDArray, OCTAVE_API) |
|
124 SND_CMP_OP_DECLS (bool, boolNDArray, OCTAVE_API) |
4669
|
125 |
4514
|
126 #endif |
|
127 |
|
128 /* |
|
129 ;;; Local Variables: *** |
|
130 ;;; mode: C++ *** |
|
131 ;;; End: *** |
|
132 */ |