# HG changeset patch # User jwe # Date 1189201690 0 # Node ID cd2c6a69a70d18ecb3156c0c556ae47c8a8db24e # Parent e00a8f661f06f359dd4a3d33417fcab0e228aa47 [project @ 2007-09-07 21:48:09 by jwe] diff -r e00a8f661f06 -r cd2c6a69a70d liboctave/Array.cc --- a/liboctave/Array.cc Fri Sep 07 21:39:56 2007 +0000 +++ b/liboctave/Array.cc Fri Sep 07 21:48:10 2007 +0000 @@ -1217,11 +1217,8 @@ T * Array::fortran_vec (void) { - if (rep->count > 1) - { - --rep->count; - rep = new typename Array::ArrayRep (*rep); - } + make_unique (); + return rep->data; } @@ -1256,7 +1253,7 @@ template void -Array::clear_index (void) +Array::clear_index (void) const { delete [] idx; idx = 0; @@ -1265,7 +1262,7 @@ template void -Array::set_index (const idx_vector& idx_arg) +Array::set_index (const idx_vector& idx_arg) const { int nd = ndims (); @@ -2012,7 +2009,7 @@ template Array -Array::value (void) +Array::value (void) const { Array retval; diff -r e00a8f661f06 -r cd2c6a69a70d liboctave/Array.h --- a/liboctave/Array.h Fri Sep 07 21:39:56 2007 +0000 +++ b/liboctave/Array.h Fri Sep 07 21:48:10 2007 +0000 @@ -143,8 +143,8 @@ protected: - idx_vector *idx; - int idx_count; + mutable idx_vector *idx; + mutable int idx_count; Array (T *d, octave_idx_type n) : rep (new typename Array::ArrayRep (d, n)), dimensions (n), @@ -493,9 +493,9 @@ void maybe_delete_dims (void); - void clear_index (void); + void clear_index (void) const; - void set_index (const idx_vector& i); + void set_index (const idx_vector& i) const; int index_count (void) const { return idx_count; } @@ -513,7 +513,7 @@ void maybe_delete_elements (Array& ra_idx, const T& rfv); - Array value (void); + Array value (void) const; Array index (idx_vector& i, int resize_ok = 0, const T& rfv = resize_fill_value (T ())) const; diff -r e00a8f661f06 -r cd2c6a69a70d liboctave/ChangeLog --- a/liboctave/ChangeLog Fri Sep 07 21:39:56 2007 +0000 +++ b/liboctave/ChangeLog Fri Sep 07 21:48:10 2007 +0000 @@ -1,3 +1,12 @@ +2007-09-07 John W. Eaton + + * Array.cc (Array::fortran_vec): Call make_unique instead of + manipulating rep directly. + + * Array.h (idx, idx_count): Declare mutable. + (Array::set_index, Array::clear_index, Array::value): + Now const. + 2007-09-06 David Bateman * Array-util.cc (increment_index): dimensions can have singleton diff -r e00a8f661f06 -r cd2c6a69a70d src/DLD-FUNCTIONS/bsxfun.cc --- a/src/DLD-FUNCTIONS/bsxfun.cc Fri Sep 07 21:39:56 2007 +0000 +++ b/src/DLD-FUNCTIONS/bsxfun.cc Fri Sep 07 21:48:10 2007 +0000 @@ -133,8 +133,8 @@ argument and a scalar.\n\ \n\ The dimensions of @var{a} and @var{b} must be equal or singleton. The\n\ -singleton dimensions a the matirces will be expanded to the same\n\ -dimensioanlity as the other matrix.\n\ +singleton dimensions of the matirces will be expanded to the same\n\ +dimensionality as the other matrix.\n\ \n\ @seealso{arrayfun, cellfun}\n\ @end deftypefn")