Mercurial > hg > octave-lyh
comparison src/ov-complex.h @ 9853:8d9e4752441a
implement complex built-in logical conversions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 23 Nov 2009 10:48:31 +0100 |
parents | f80c566bc751 |
children | b3089dba88bf |
comparison
equal
deleted
inserted
replaced
9852:aabf7a8c2e57 | 9853:8d9e4752441a |
---|---|
32 #include "lo-ieee.h" | 32 #include "lo-ieee.h" |
33 #include "mx-base.h" | 33 #include "mx-base.h" |
34 #include "oct-alloc.h" | 34 #include "oct-alloc.h" |
35 #include "str-vec.h" | 35 #include "str-vec.h" |
36 | 36 |
37 #include "gripes.h" | |
37 #include "error.h" | 38 #include "error.h" |
38 #include "ov-base.h" | 39 #include "ov-base.h" |
39 #include "ov-cx-mat.h" | 40 #include "ov-cx-mat.h" |
40 #include "ov-base-scalar.h" | 41 #include "ov-base-scalar.h" |
41 #include "ov-typeinfo.h" | 42 #include "ov-typeinfo.h" |
132 FloatComplexMatrix float_complex_matrix_value (bool = false) const; | 133 FloatComplexMatrix float_complex_matrix_value (bool = false) const; |
133 | 134 |
134 ComplexNDArray complex_array_value (bool = false) const; | 135 ComplexNDArray complex_array_value (bool = false) const; |
135 | 136 |
136 FloatComplexNDArray float_complex_array_value (bool = false) const; | 137 FloatComplexNDArray float_complex_array_value (bool = false) const; |
138 | |
139 bool bool_value (bool warn = false) const | |
140 { | |
141 if (xisnan (scalar)) | |
142 error ("invalid conversion from NaN to logical"); | |
143 else if (warn && scalar != 0.0 && scalar != 1.0) | |
144 gripe_logical_conversion (); | |
145 | |
146 return scalar != 0.0; | |
147 } | |
148 | |
149 boolNDArray bool_array_value (bool warn = false) const | |
150 { | |
151 if (xisnan (scalar)) | |
152 error ("invalid conversion from NaN to logical"); | |
153 else if (warn && scalar != 0.0 && scalar != 1.0) | |
154 gripe_logical_conversion (); | |
155 | |
156 return boolNDArray (dim_vector (1, 1), scalar != 0.0); | |
157 } | |
137 | 158 |
138 void increment (void) { scalar += 1.0; } | 159 void increment (void) { scalar += 1.0; } |
139 | 160 |
140 void decrement (void) { scalar -= 1.0; } | 161 void decrement (void) { scalar -= 1.0; } |
141 | 162 |