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