comparison libinterp/octave-value/ov-cx-mat.cc @ 19510:d0c73e23a505

Change inheritance tree so that <T>Matrix inherit from <T>NDArray. * liboctave/array/CMatrix.cc, liboctave/array/CMatrix.h, liboctave/array/CNDArray.cc, liboctave/array/CNDArray.h, liboctave/array/dMatrix.cc, liboctave/array/dMatrix.h, liboctave/array/dNDArray.cc, liboctave/array/dNDArray.h, liboctave/array/fCMatrix.cc, liboctave/array/fCMatrix.h, liboctave/array/fCNDArray.cc, liboctave/array/fCNDArray.h, liboctave/array/fMatrix.cc, liboctave/array/fMatrix.h, liboctave/array/fNDArray.cc, liboctave/array/fNDArray.h: change base class of Matrix, FloatMatrix, ComplexMatrix, and FloatComplexMatrix to NDArray, FloatNDArray, ComplexNDArray, and FloatComplexNDArray respectively. This will allow to reduce duplicated code since the Matrix classes will be able to inherit many of their methods from their NDArray counterparts. Also remove the matrix_value () method since a constructor now suffices. * liboctave/array/CSparse.h: include CMatrix * libinterp/corefcn/pr-output.cc, libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-flt-cx-mat.cc, libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-re-mat.cc: replace calls to matrix_value () with constructor with respective Matrix subclass.
author Carnë Draug <carandraug@octave.org>
date Fri, 07 Nov 2014 08:15:55 +0000
parents 6a71e5030df5
children 76478d2da117
comparison
equal deleted inserted replaced
19509:8b4a24081e47 19510:d0c73e23a505
150 150
151 if (! force_conversion) 151 if (! force_conversion)
152 gripe_implicit_conversion ("Octave:imag-to-real", 152 gripe_implicit_conversion ("Octave:imag-to-real",
153 "complex matrix", "real matrix"); 153 "complex matrix", "real matrix");
154 154
155 retval = ::real (matrix.matrix_value ()); 155 retval = ::real (ComplexMatrix (matrix));
156 156
157 return retval; 157 return retval;
158 } 158 }
159 159
160 FloatMatrix 160 FloatMatrix
164 164
165 if (! force_conversion) 165 if (! force_conversion)
166 gripe_implicit_conversion ("Octave:imag-to-real", 166 gripe_implicit_conversion ("Octave:imag-to-real",
167 "complex matrix", "real matrix"); 167 "complex matrix", "real matrix");
168 168
169 retval = ::real (matrix.matrix_value ()); 169 retval = ::real (ComplexMatrix (matrix));
170 170
171 return retval; 171 return retval;
172 } 172 }
173 173
174 Complex 174 Complex
212 } 212 }
213 213
214 ComplexMatrix 214 ComplexMatrix
215 octave_complex_matrix::complex_matrix_value (bool) const 215 octave_complex_matrix::complex_matrix_value (bool) const
216 { 216 {
217 return matrix.matrix_value (); 217 return ComplexMatrix (matrix);
218 } 218 }
219 219
220 FloatComplexMatrix 220 FloatComplexMatrix
221 octave_complex_matrix::float_complex_matrix_value (bool) const 221 octave_complex_matrix::float_complex_matrix_value (bool) const
222 { 222 {
223 return FloatComplexMatrix (matrix.matrix_value ()); 223 return FloatComplexMatrix (ComplexMatrix (matrix));
224 } 224 }
225 225
226 boolNDArray 226 boolNDArray
227 octave_complex_matrix::bool_array_value (bool warn) const 227 octave_complex_matrix::bool_array_value (bool warn) const
228 { 228 {
268 268
269 if (! force_conversion) 269 if (! force_conversion)
270 gripe_implicit_conversion ("Octave:imag-to-real", 270 gripe_implicit_conversion ("Octave:imag-to-real",
271 "complex matrix", "real matrix"); 271 "complex matrix", "real matrix");
272 272
273 retval = SparseMatrix (::real (matrix.matrix_value ())); 273 retval = SparseMatrix (::real (ComplexMatrix (matrix)));
274 274
275 return retval; 275 return retval;
276 } 276 }
277 277
278 SparseComplexMatrix 278 SparseComplexMatrix
279 octave_complex_matrix::sparse_complex_matrix_value (bool) const 279 octave_complex_matrix::sparse_complex_matrix_value (bool) const
280 { 280 {
281 return SparseComplexMatrix (matrix.matrix_value ()); 281 return SparseComplexMatrix (ComplexMatrix (matrix));
282 } 282 }
283 283
284 octave_value 284 octave_value
285 octave_complex_matrix::diag (octave_idx_type k) const 285 octave_complex_matrix::diag (octave_idx_type k) const
286 { 286 {
300 octave_value retval; 300 octave_value retval;
301 301
302 if (matrix.ndims () == 2 302 if (matrix.ndims () == 2
303 && (matrix.rows () == 1 || matrix.columns () == 1)) 303 && (matrix.rows () == 1 || matrix.columns () == 1))
304 { 304 {
305 ComplexMatrix mat = matrix.matrix_value (); 305 ComplexMatrix mat (matrix);
306 306
307 retval = mat.diag (m, n); 307 retval = mat.diag (m, n);
308 } 308 }
309 else 309 else
310 error ("diag: expecting vector argument"); 310 error ("diag: expecting vector argument");