Mercurial > hg > octave-nkf
annotate liboctave/boolNDArray.h @ 9621:3ee9029931b3
fix scalar complex-real comparisons
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 06 Sep 2009 07:41:34 +0200 |
parents | 1be3c73ed7b5 |
children | b29504415a2e |
rev | line source |
---|---|
4514 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 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" | |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8756
diff
changeset
|
29 #include "mx-op-decl.h" |
4514 | 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 | |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
62 boolNDArray& invert (void); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
63 |
8626
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
7620
diff
changeset
|
64 bool any_element_is_nan (void) const { return false; } |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
7620
diff
changeset
|
65 |
5775 | 66 // FIXME -- this is not quite the right thing. |
4514 | 67 |
4556 | 68 boolNDArray all (int dim = -1) const; |
69 boolNDArray any (int dim = -1) const; | |
4514 | 70 |
8756
d0755c9db5ed
implement fast logical sum (counting)
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
71 NDArray sum (int dim = -1) const; |
8780
ea76466605ba
support native cumsum, gripe on overflow in sum/cumsum
Jaroslav Hajek <highegg@gmail.com>
parents:
8774
diff
changeset
|
72 NDArray cumsum (int dim = -1) const; |
7113 | 73 |
5275 | 74 boolNDArray concat (const boolNDArray& rb, const Array<octave_idx_type>& ra_idx); |
4964 | 75 |
5275 | 76 boolNDArray& insert (const boolNDArray& a, octave_idx_type r, octave_idx_type c); |
77 boolNDArray& insert (const boolNDArray& a, const Array<octave_idx_type>& ra_idx); | |
4964 | 78 |
4514 | 79 boolMatrix matrix_value (void) const; |
80 | |
4532 | 81 boolNDArray squeeze (void) const { return ArrayN<bool>::squeeze (); } |
82 | |
5275 | 83 static void increment_index (Array<octave_idx_type>& ra_idx, |
4532 | 84 const dim_vector& dimensions, |
85 int start_dimension = 0); | |
86 | |
5275 | 87 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx, |
4556 | 88 const dim_vector& dimensions); |
89 | |
4514 | 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 static bool resize_fill_value (void) { return false; } | |
96 | |
97 // bool all_elements_are_real (void) const; | |
98 // bool all_integers (double& max_val, double& min_val) const; | |
99 | |
5602 | 100 octave_idx_type nnz (void) const |
101 { | |
102 octave_idx_type retval = 0; | |
103 | |
104 const bool *d = this->data (); | |
105 | |
106 octave_idx_type nel = this->numel (); | |
107 | |
108 for (octave_idx_type i = 0; i < nel; i++) | |
109 { | |
110 if (d[i]) | |
111 retval++; | |
112 } | |
113 | |
114 return retval; | |
115 } | |
116 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
117 boolNDArray diag (octave_idx_type k = 0) const; |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
118 |
4514 | 119 private: |
120 | |
4587 | 121 boolNDArray (bool *d, dim_vector& dv) : ArrayN<bool> (d, dv) { } |
4514 | 122 }; |
123 | |
6708 | 124 NDND_BOOL_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API) |
125 NDND_CMP_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API) | |
4543 | 126 |
6708 | 127 NDS_BOOL_OP_DECLS (boolNDArray, bool, OCTAVE_API) |
128 NDS_CMP_OP_DECLS (boolNDArray, bool, OCTAVE_API) | |
4669 | 129 |
6708 | 130 SND_BOOL_OP_DECLS (bool, boolNDArray, OCTAVE_API) |
131 SND_CMP_OP_DECLS (bool, boolNDArray, OCTAVE_API) | |
4669 | 132 |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
133 extern OCTAVE_API boolNDArray& |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
134 mx_el_and_assign (boolNDArray& m, const boolNDArray& a); |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
135 extern OCTAVE_API boolNDArray& |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
136 mx_el_or_assign (boolNDArray& m, const boolNDArray& a); |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
137 |
4514 | 138 #endif |
139 | |
140 /* | |
141 ;;; Local Variables: *** | |
142 ;;; mode: C++ *** | |
143 ;;; End: *** | |
144 */ |