comparison src/ov-str-mat.cc @ 4668:7849788ca4bd

[project @ 2003-11-26 04:28:39 by jwe]
author jwe
date Wed, 26 Nov 2003 04:28:39 +0000
parents ef3a14fb6847
children e95c86d48732
comparison
equal deleted inserted replaced
4667:e6260247a166 4668:7849788ca4bd
48 static octave_value * 48 static octave_value *
49 default_numeric_conversion_function (const octave_value& a) 49 default_numeric_conversion_function (const octave_value& a)
50 { 50 {
51 CAST_CONV_ARG (const octave_char_matrix_str&); 51 CAST_CONV_ARG (const octave_char_matrix_str&);
52 52
53 Matrix m = v.matrix_value (true); 53 NDArray nda = v.array_value (true);
54 54
55 return error_state ? 0 : new octave_matrix (m); 55 return error_state ? 0 : new octave_matrix (nda);
56 } 56 }
57 57
58 type_conv_fcn 58 type_conv_fcn
59 octave_char_matrix_str::numeric_conversion_function (void) const 59 octave_char_matrix_str::numeric_conversion_function (void) const
60 { 60 {
129 bool retval = false; 129 bool retval = false;
130 error ("octave_char_matrix_str::valid_as_scalar_index(): not implemented"); 130 error ("octave_char_matrix_str::valid_as_scalar_index(): not implemented");
131 return retval; 131 return retval;
132 } 132 }
133 133
134 #define CHAR_MATRIX_CONV(T, INIT, TNAME, FCN) \
135 T retval INIT; \
136 \
137 if (! force_string_conv) \
138 gripe_invalid_conversion ("string", TNAME); \
139 else \
140 { \
141 if (Vwarn_str_to_num) \
142 gripe_implicit_conversion ("string", TNAME); \
143 \
144 retval = octave_char_matrix::FCN (); \
145 } \
146 \
147 return retval
148
134 double 149 double
135 octave_char_matrix_str::double_value (bool force_string_conv) const 150 octave_char_matrix_str::double_value (bool force_string_conv) const
136 { 151 {
137 double retval = 0; 152 CHAR_MATRIX_CONV (double, = 0, "real scalar", double_value);
138 153 }
139 if (! force_string_conv) 154
140 gripe_invalid_conversion ("string", "real scalar"); 155 Complex
141 else 156 octave_char_matrix_str::complex_value (bool force_string_conv) const
142 { 157 {
143 if (Vwarn_str_to_num) 158 CHAR_MATRIX_CONV (Complex, = 0, "complex scalar", complex_value);
144 gripe_implicit_conversion ("string", "real scalar");
145
146 retval = octave_char_matrix::double_value ();
147 }
148
149 return retval;
150 } 159 }
151 160
152 Matrix 161 Matrix
153 octave_char_matrix_str::matrix_value (bool force_string_conv) const 162 octave_char_matrix_str::matrix_value (bool force_string_conv) const
154 { 163 {
155 Matrix retval; 164 CHAR_MATRIX_CONV (Matrix, , "real matrix", matrix_value);
156 165 }
157 if (! force_string_conv) 166
158 gripe_invalid_conversion ("string", "real matrix"); 167 ComplexMatrix
159 else 168 octave_char_matrix_str::complex_matrix_value (bool force_string_conv) const
160 { 169 {
161 if (Vwarn_str_to_num) 170 CHAR_MATRIX_CONV (ComplexMatrix, , "complex matrix", complex_matrix_value);
162 gripe_implicit_conversion ("string", "real matrix"); 171 }
163 172
164 retval = octave_char_matrix::matrix_value (); 173 NDArray
165 } 174 octave_char_matrix_str::array_value (bool force_string_conv) const
166 175 {
167 return retval; 176 CHAR_MATRIX_CONV (NDArray, , "real N-d array", array_value);
177 }
178
179 ComplexNDArray
180 octave_char_matrix_str::complex_array_value (bool force_string_conv) const
181 {
182 CHAR_MATRIX_CONV (ComplexNDArray, , "complex N-d array",
183 complex_array_value);
168 } 184 }
169 185
170 string_vector 186 string_vector
171 octave_char_matrix_str::all_strings (bool, bool) const 187 octave_char_matrix_str::all_strings (bool, bool) const
172 { 188 {