Mercurial > hg > octave-nkf
comparison liboctave/array/dMatrix.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 | 65554f5847ac |
children | 3746b92739f7 |
comparison
equal
deleted
inserted
replaced
19509:8b4a24081e47 | 19510:d0c73e23a505 |
---|---|
244 } | 244 } |
245 | 245 |
246 // Matrix class. | 246 // Matrix class. |
247 | 247 |
248 Matrix::Matrix (const RowVector& rv) | 248 Matrix::Matrix (const RowVector& rv) |
249 : MArray<double> (rv) | 249 : NDArray (rv) |
250 { | 250 { |
251 } | 251 } |
252 | 252 |
253 Matrix::Matrix (const ColumnVector& cv) | 253 Matrix::Matrix (const ColumnVector& cv) |
254 : MArray<double> (cv) | 254 : NDArray (cv) |
255 { | 255 { |
256 } | 256 } |
257 | 257 |
258 Matrix::Matrix (const DiagMatrix& a) | 258 Matrix::Matrix (const DiagMatrix& a) |
259 : MArray<double> (a.dims (), 0.0) | 259 : NDArray (a.dims (), 0.0) |
260 { | 260 { |
261 for (octave_idx_type i = 0; i < a.length (); i++) | 261 for (octave_idx_type i = 0; i < a.length (); i++) |
262 elem (i, i) = a.elem (i, i); | 262 elem (i, i) = a.elem (i, i); |
263 } | 263 } |
264 | 264 |
265 Matrix::Matrix (const PermMatrix& a) | 265 Matrix::Matrix (const PermMatrix& a) |
266 : MArray<double> (a.dims (), 0.0) | 266 : NDArray (a.dims (), 0.0) |
267 { | 267 { |
268 const Array<octave_idx_type> ia (a.col_perm_vec ()); | 268 const Array<octave_idx_type> ia (a.col_perm_vec ()); |
269 octave_idx_type len = a.rows (); | 269 octave_idx_type len = a.rows (); |
270 for (octave_idx_type i = 0; i < len; i++) | 270 for (octave_idx_type i = 0; i < len; i++) |
271 elem (ia(i), i) = 1.0; | 271 elem (ia(i), i) = 1.0; |
272 } | 272 } |
273 | 273 |
274 // FIXME: could we use a templated mixed-type copy function here? | 274 // FIXME: could we use a templated mixed-type copy function here? |
275 | 275 |
276 Matrix::Matrix (const boolMatrix& a) | 276 Matrix::Matrix (const boolMatrix& a) |
277 : MArray<double> (a) | 277 : NDArray (a) |
278 { | 278 { |
279 } | 279 } |
280 | 280 |
281 Matrix::Matrix (const charMatrix& a) | 281 Matrix::Matrix (const charMatrix& a) |
282 : MArray<double> (a.dims ()) | 282 : NDArray (a.dims ()) |
283 { | 283 { |
284 for (octave_idx_type i = 0; i < a.rows (); i++) | 284 for (octave_idx_type i = 0; i < a.rows (); i++) |
285 for (octave_idx_type j = 0; j < a.cols (); j++) | 285 for (octave_idx_type j = 0; j < a.cols (); j++) |
286 elem (i, j) = static_cast<unsigned char> (a.elem (i, j)); | 286 elem (i, j) = static_cast<unsigned char> (a.elem (i, j)); |
287 } | 287 } |
2798 } | 2798 } |
2799 | 2799 |
2800 Matrix | 2800 Matrix |
2801 Matrix::diag (octave_idx_type k) const | 2801 Matrix::diag (octave_idx_type k) const |
2802 { | 2802 { |
2803 return MArray<double>::diag (k); | 2803 return NDArray::diag (k); |
2804 } | 2804 } |
2805 | 2805 |
2806 DiagMatrix | 2806 DiagMatrix |
2807 Matrix::diag (octave_idx_type m, octave_idx_type n) const | 2807 Matrix::diag (octave_idx_type m, octave_idx_type n) const |
2808 { | 2808 { |