Mercurial > hg > octave-terminal
changeset 4834:8f669cc5a901
[project @ 2004-03-11 18:49:17 by jwe]
author | jwe |
---|---|
date | Thu, 11 Mar 2004 18:49:17 +0000 |
parents | 399e8681b774 |
children | 66645e416d55 |
files | liboctave/Array.cc liboctave/Array.h liboctave/ChangeLog scripts/ChangeLog scripts/signal/sinewave.m src/ChangeLog src/ov-base-mat.cc |
diffstat | 7 files changed, 49 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -46,6 +46,17 @@ // all the derived classes. template <class T> +Array<T>::Array (const Array<T>& a, const dim_vector& dv) + : rep (a.rep), dimensions (dv), idx (0), idx_count (0) +{ + rep->count++; + + if (a.numel () < dv.numel ()) + (*current_liboctave_error_handler) + ("Array::Array (const Array&, const dim_vector&): dimension mismatch"); +} + +template <class T> Array<T>::~Array (void) { if (--rep->count <= 0)
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -202,11 +202,7 @@ fill (val); } - Array (const Array<T>& a, const dim_vector& dv) - : rep (a.rep), dimensions (dv), idx (0), idx_count (0) - { - rep->count++; - } + Array (const Array<T>& a, const dim_vector& dv); ~Array (void);
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +2004-03-11 John W. Eaton <jwe@bevo.che.wisc.edu> + + * Array.cc (Array<T>::Array (const Array<T>&, const dim_vector&)): + Move here from Array.h, check that size of array arg is not + smaller than the size defined by the new dimensions. + 2004-03-10 John W. Eaton <jwe@bevo.che.wisc.edu> * Array.cc (Array<T>::index2): Allow result to be N-d if indexing
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2004-03-10 Volker Kuhlmann <VolkerKuhlmann@gmx.de> + + * signal/sinewave.m: Allow N to default to M. + 2004-03-09 John W. Eaton <jwe@bevo.che.wisc.edu> * signal/unwrap.m: Use "isempty (tol)" instead of "tol == []".
--- a/scripts/signal/sinewave.m +++ b/scripts/signal/sinewave.m @@ -22,7 +22,8 @@ ## Return an @var{m}-element vector with @var{i}-th element given by ## @code{sin (2 * pi * (@var{i}+@var{d}-1) / @var{n})}. ## -## The default value for @var{d} is 0. +## The default value for @var{d} is 0 and the default value for @var{n} +## is @var{m}. ## @end deftypefn ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> @@ -30,12 +31,16 @@ function x = sinewave (m, n, d) - if (nargin == 2) - d = 0; - elseif (nargin != 3) + if (nargin > 0 && nargin < 4) + if (nargin < 3) + d = 0; + endif + if (nargin < 2) + n = m; + endif + x = sin (((1 : m) + d - 1) * 2 * pi / n); + else usage ("sinewave (m, n, d)"); endif - x = sin (((1 : m) + d - 1) * 2 * pi / n); - endfunction
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-03-11 John W. Eaton <jwe@bevo.che.wisc.edu> + + * ov-base-mat.cc (octave_base_matrix<MT>::subsasgn): If empty, + allow type conversion when indexing with "{" and ".". + 2004-03-10 John W. Eaton <jwe@bevo.che.wisc.edu> * pr-output.cc (init_format_state): Also set compact_format.
--- a/src/ov-base-mat.cc +++ b/src/ov-base-mat.cc @@ -102,8 +102,17 @@ case '{': case '.': { - std::string nm = type_name (); - error ("%s cannot be indexed with %c", nm.c_str (), type[0]); + if (is_empty ()) + { + octave_value tmp = octave_value::empty_conv (type, rhs); + + retval = tmp.subsasgn (type, idx, rhs); + } + else + { + std::string nm = type_name (); + error ("%s cannot be indexed with %c", nm.c_str (), type[0]); + } } break;