Mercurial > hg > octave-terminal
changeset 10545:ffe28cdc6fe2
fix reshape() and permute() for scalars
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 23 Apr 2010 11:42:58 +0200 |
parents | 9961fc022d9d |
children | f5b8b28917a2 |
files | src/ChangeLog src/ov-base-scalar.cc src/ov-base-scalar.h |
diffstat | 3 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-04-23 Jaroslav Hajek <highegg@gmail.com> + + * ov-base-scalar.h (octave_base_scalar::reshape, + octave_base_scalar::permute): Remove implementations. + * ov-base-scalar.cc (octave_base_scalar::reshape, + octave_base_scalar::permute): Provide correct implementations here. + 2010-04-23 Jaroslav Hajek <highegg@gmail.com> * ov-bool.h (octave_bool::empty_clone): Correctly return an empty
--- a/src/ov-base-scalar.cc +++ b/src/ov-base-scalar.cc @@ -101,6 +101,20 @@ } template <class ST> +octave_value +octave_base_scalar<ST>::permute (const Array<int>& vec, bool inv) const +{ + return Array<ST> (1, 1, scalar).permute (vec, inv); +} + +template <class ST> +octave_value +octave_base_scalar<ST>::reshape (const dim_vector& new_dims) const +{ + return Array<ST> (1, 1, scalar).reshape (new_dims); +} + +template <class ST> bool octave_base_scalar<ST>::is_true (void) const {
--- a/src/ov-base-scalar.h +++ b/src/ov-base-scalar.h @@ -80,11 +80,9 @@ octave_idx_type nnz (void) const { return (scalar != ST ()) ? 1 : 0; } - octave_value permute (const Array<int>&, bool = false) const - { return scalar; } + octave_value permute (const Array<int>&, bool = false) const; - octave_value reshape (const dim_vector& new_dims) const - { return array_value ().reshape (new_dims); } + octave_value reshape (const dim_vector& new_dims) const; size_t byte_size (void) const { return sizeof (ST); }