# HG changeset patch # User jwe # Date 1079030957 0 # Node ID 8f669cc5a901a03e0541292ebdaec3f3eead7941 # Parent 399e8681b7745f63cc26be0841d21f550aaa519c [project @ 2004-03-11 18:49:17 by jwe] diff --git a/liboctave/Array.cc b/liboctave/Array.cc --- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -46,6 +46,17 @@ // all the derived classes. template +Array::Array (const Array& 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 Array::~Array (void) { if (--rep->count <= 0) diff --git a/liboctave/Array.h b/liboctave/Array.h --- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -202,11 +202,7 @@ fill (val); } - Array (const Array& a, const dim_vector& dv) - : rep (a.rep), dimensions (dv), idx (0), idx_count (0) - { - rep->count++; - } + Array (const Array& a, const dim_vector& dv); ~Array (void); diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +2004-03-11 John W. Eaton + + * Array.cc (Array::Array (const Array&, 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 * Array.cc (Array::index2): Allow result to be N-d if indexing diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2004-03-10 Volker Kuhlmann + + * signal/sinewave.m: Allow N to default to M. + 2004-03-09 John W. Eaton * signal/unwrap.m: Use "isempty (tol)" instead of "tol == []". diff --git a/scripts/signal/sinewave.m b/scripts/signal/sinewave.m --- 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 @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-03-11 John W. Eaton + + * ov-base-mat.cc (octave_base_matrix::subsasgn): If empty, + allow type conversion when indexing with "{" and ".". + 2004-03-10 John W. Eaton * pr-output.cc (init_format_state): Also set compact_format. diff --git a/src/ov-base-mat.cc b/src/ov-base-mat.cc --- 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;