Mercurial > hg > octave-terminal
changeset 10653:ec5fa46e0e45
override ndims and numel for scalars and matrices
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 25 May 2010 08:53:58 +0200 |
parents | 2f0fbfa4dd23 |
children | 984b8b6bee02 |
files | src/ChangeLog src/ov-base-mat.h src/ov-base-scalar.h |
diffstat | 3 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-05-25 Jaroslav Hajek <highegg@gmail.com> + + * ov-base-mat.h (octave_base_matrix::ndims): New override. + * ov-base-scalar.h (octave_base_scalar::numel, + octave_base_scalar::ndims): New overrides. + 2010-05-25 Jaroslav Hajek <highegg@gmail.com> * ov-base.cc (octave_base_value::ndims): Remove fallback
--- a/src/ov-base-mat.h +++ b/src/ov-base-mat.h @@ -102,6 +102,8 @@ octave_idx_type numel (void) const { return matrix.numel (); } + int ndims (void) const { return matrix.ndims (); } + octave_idx_type nnz (void) const { return matrix.nnz (); } octave_value reshape (const dim_vector& new_dims) const
--- a/src/ov-base-scalar.h +++ b/src/ov-base-scalar.h @@ -78,6 +78,10 @@ dim_vector dims (void) const { static dim_vector dv (1, 1); return dv; } + octave_idx_type numel (void) const { return 1; } + + int ndims (void) const { return 2; } + octave_idx_type nnz (void) const { return (scalar != ST ()) ? 1 : 0; } octave_value permute (const Array<int>&, bool = false) const;