changeset 6881:cd2c6a69a70d

[project @ 2007-09-07 21:48:09 by jwe]
author jwe
date Fri, 07 Sep 2007 21:48:10 +0000
parents e00a8f661f06
children 62cf34f42539
files liboctave/Array.cc liboctave/Array.h liboctave/ChangeLog src/DLD-FUNCTIONS/bsxfun.cc
diffstat 4 files changed, 21 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- 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<T>::fortran_vec (void)
 {
-  if (rep->count > 1)
-    {
-      --rep->count;
-      rep = new typename Array<T>::ArrayRep (*rep);
-    }
+  make_unique ();
+
   return rep->data;
 }
 
@@ -1256,7 +1253,7 @@
 
 template <class T>
 void
-Array<T>::clear_index (void)
+Array<T>::clear_index (void) const
 {
   delete [] idx;
   idx = 0;
@@ -1265,7 +1262,7 @@
 
 template <class T>
 void
-Array<T>::set_index (const idx_vector& idx_arg)
+Array<T>::set_index (const idx_vector& idx_arg) const
 {
   int nd = ndims ();
 
@@ -2012,7 +2009,7 @@
 
 template <class T>
 Array<T>
-Array<T>::value (void)
+Array<T>::value (void) const
 {
   Array<T> retval;
 
--- 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<T>::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<idx_vector>& ra_idx, const T& rfv);
 
-  Array<T> value (void);
+  Array<T> value (void) const;
 
   Array<T> index (idx_vector& i, int resize_ok = 0,
 		  const T& rfv = resize_fill_value (T ())) const;
--- 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  <jwe@octave.org>
+
+	* Array.cc (Array<T>::fortran_vec): Call make_unique instead of
+	manipulating rep directly.
+
+	* Array.h (idx, idx_count): Declare mutable.
+	(Array<T>::set_index, Array<T>::clear_index, Array<T>::value):
+	Now const.
+
 2007-09-06  David Bateman  <dbateman@free.fr>
 
         * Array-util.cc (increment_index): dimensions can have singleton
--- 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")