# HG changeset patch # User John W. Eaton # Date 1336681862 14400 # Node ID 13cc11418393d8b74c67501227f1057045f5b125 # Parent 88e67d58b06b1397c4894c091b2692080f7c06f0 improve handling of default resize fill value for arrays * Array.cc (Array::resize_fill_value): Return T, not const T&. * Array.h (Array::resize_fill_value): Now virtual member function instead of static. (Array::resize1 (octave_idx_type)): New function. (Array::resize1 (octave_idx_type, const T&)): Eliminate default value for second arg. (Array::resize (octave_idx_type, octave_idx_type)): New function. (Array::resize (octave_idx_type, octave_idx_type, const T&)): Eliminate default value for third arg. (Array::resize (const dim_vector&)): New function. (Array::resize (const dim_vector&, const T&)): New function. (Array::resize2 (octave_idx_type, octave_idx_type)): New function. (Array::resize2 (octave_idx_type, octave_idx_type, const T&)): Eliminate default value for third arg. (Array::index (const idx_vector&, bool) const): New function. (Array::index (const idx_vector&, bool, const T&) const): Eliminate default value for third arg. (Array::index (const idx_vector&, const idx_vector&, bool) const): New function. (Array::index (const idx_vector&, const idx_vector&, bool, const T&) const): Eliminate default value for third arg. (Array::index (const Array&, bool) const): New function. (Array::index (const Array&, const T&) const): Eliminate default value for third arg. (Array::assign (const idx_vector&, const Array&)): New function. (Array::assign (const idx_vector&, const Array&, const T&)): Eliminate default value for third arg. (Array::assign (const idx_vector&, const idx_vector&, const Array&)): New function. (Array::assign (const idx_vector&, const idx_vector&, const Array&, const T&)): Eliminate default value for third arg. (Array::assign (const Array&, const Array&)): New function. (Array::assign (const Array&, const Array&, const T&)): Eliminate default value for third arg. * DiagArray2.h (DiagArray2::resize (octave_idx_type, octave_idx_type)): New function. (DiagArray2::resize (octave_idx_type, octave_idx_type, const T&)): Eliminate default value for third arg. * CColVector.h (ComplexColumnVector::resize): Use Complex (0) as default value instead of Array::resize_fill_value (). * CMatrix.h (ComplexMatrix::resize): Use Complex (0) as default value instead of Array::resize_fill_value (). (ComplexMatrix::resize_fill_value): Delete. * CNDArray.h (ComplexNDArray::resize_fill_value): Delete. * CRowVector.h (ComplexRowVector::resize): Use Complex (0) as default value instead of Array::resize_fill_value (). * boolMatrix.h (boolMatrix::resize): Use false as default value instead of resize_fill_value (). (boolMatrix::resize_fill_value): Delete. * boolNDArray.h (boolNDArray::resize_fill_value): Delete. * chMatrix.h (charMatrix::resize): Use 0 as default value instead of resize_fill_value. (charMatrix::resize_fill_value): Delete. * chNDArray.h (charNDArray::resize_fill_value): Delete. * dColVector.h (ColumnVector::resize): Use 0 as default value instead of Array::resize_fill_value (). * dMatrix.h (Matrix::resize): Use 0 as default value instead of resize_fill_value (). (Matrix::resize_fill_value): Delete. * dNDArray.h (NDArray::resize_fill_value): Delete. * dRowVector.h (RowVector::resize): Use 0 as default value instead of Array::resize_fill_value (). * fCColVector.h (FloatComplexColumnVector::resize): Use FloatComplex (0) as default value instead of Array::resize_fill_value (). * fCMatrix.h (FloatComplexMatrix::resize): Use FloatComplex (0) as default value instead of resize_fill_value ()). FloatCmplexMatrix::resize_fill_value): Delete. * fCNDArray.h (FloatComplexNDArray::resize_fill_value): Delete. * fCRowVector.h (FloatComplexRowVector::resize): Use FloatComplex (0) as default value instead of Array::resize_fill_value (). * fColVector.h (FloatColumnVector::resize): Use 0 as default value instead of Array::resize_fill_value (). * fMatrix.h (FloatMatrix::resize): Use 0 as default value instead of resize_fill_value (). * fMatrix.h (FloatMatrix::resize_fill_value): Delete. * fNDArray.h (FloatNDArray::resize_fill_value): Delete. * fRowVector.h (FloatRowVector::resize): Use 0 as default value instead of Array::resize_fill_value (). * intNDArray.h (intNDArray::resize_fill_value): Delete. * str-vec.h (string_vector::resize): Use std::string as default value instead of resize_fill_value (). * Cell.cc, Cell.h (Cell::Cell, Cell::assign, Cell::index): Use Matrix () as default value instead of resize_fill_value (). (Cell::resize_fill_value): No longer static. * oct-map.cc (octave_map::resize, octave_map::assign, Octave_map::resize, Octave_map::assign): Use Matrix () as default value instead of Cell::resize_fill_value. * oct-obj.h (octave_value_list::resize): Use octave_value () instead of Array::resize_fill_value (). * ov-complex.cc (octave_complex::resize): Use Complex (0) for fill value instead of ComplexNDArray::resize_fill_value (). * ov-float.cc (octave_float_scalar::resize): Use 0 for fill value instead of NDArray::resize_fill_value (). * ov-flt-complex.cc (octave_float_complex_scalar::resize): Use Complex (0) for fill value instead of ComplexNDArray::resize_fill_value (). * ov-range.cc (octave_range::resize): Use 0 for fill value instead of NDArray::resize_fill_value (). * ov-scalar.cc (octave_scalar::resize): Use 0 for fill value instead of NDArray::resize_fill_value (). * ov-str-mat.cc (octave_char_matrix_str::resize): Use 0 for fill value instead of charNDArray::resize_fill_value (). diff -r 88e67d58b06b -r 13cc11418393 liboctave/Array.cc --- a/liboctave/Array.cc Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/Array.cc Thu May 10 16:31:02 2012 -0400 @@ -884,7 +884,8 @@ // The default fill value. Override if you want a different one. template -const T& Array::resize_fill_value () +T +Array::resize_fill_value (void) const { static T zero = T (); return zero; diff -r 88e67d58b06b -r 13cc11418393 liboctave/Array.h --- a/liboctave/Array.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/Array.h Thu May 10 16:31:02 2012 -0400 @@ -450,46 +450,69 @@ Array index (const Array& ia) const; - static const T& resize_fill_value (); + virtual T resize_fill_value (void) const; // Resizing (with fill). - void resize1 (octave_idx_type n, const T& rfv = resize_fill_value ()); + void resize1 (octave_idx_type n, const T& rfv); + void resize1 (octave_idx_type n) { resize1 (n, resize_fill_value ()); } - void resize (octave_idx_type n) GCC_ATTR_DEPRECATED - { resize1 (n); } + void resize (octave_idx_type n) GCC_ATTR_DEPRECATED { resize1 (n); } - void resize (octave_idx_type nr, octave_idx_type nc, - const T& rfv = resize_fill_value ()) GCC_ATTR_DEPRECATED + void resize (octave_idx_type nr, octave_idx_type nc, const T& rfv) GCC_ATTR_DEPRECATED { resize2 (nr, nc, rfv); } - void resize (const dim_vector& dv, const T& rfv = resize_fill_value ()); + void resize (octave_idx_type nr, octave_idx_type nc) GCC_ATTR_DEPRECATED + { + resize2 (nr, nc, resize_fill_value ()); + } + + void resize (const dim_vector& dv, const T& rfv); + void resize (const dim_vector& dv) { resize (dv, resize_fill_value ()); } // Indexing with possible resizing and fill // FIXME -- this is really a corner case, that should better be // handled directly in liboctinterp. - Array index (const idx_vector& i, bool resize_ok, - const T& rfv = resize_fill_value ()) const; + Array index (const idx_vector& i, bool resize_ok, const T& rfv) const; + Array index (const idx_vector& i, bool resize_ok) const + { + return index (i, resize_ok, resize_fill_value ()); + } - Array index (const idx_vector& i, const idx_vector& j, - bool resize_ok, const T& rfv = resize_fill_value ()) const; + Array index (const idx_vector& i, const idx_vector& j, bool resize_ok, const T& rfv) const; + Array index (const idx_vector& i, const idx_vector& j, bool resize_ok) const + { + return index (i, j, resize_ok, resize_fill_value ()); + } - Array index (const Array& ia, - bool resize_ok, const T& rfv = resize_fill_value ()) const; + Array index (const Array& ia, bool resize_ok, const T& rfv) const; + Array index (const Array& ia, bool resize_ok) const + { + return index (ia, resize_ok, resize_fill_value ()); + } // Indexed assignment (always with resize & fill). - void assign (const idx_vector& i, const Array& rhs, - const T& rfv = resize_fill_value ()); + void assign (const idx_vector& i, const Array& rhs, const T& rfv); + void assign (const idx_vector& i, const Array& rhs) + { + assign (i, rhs, resize_fill_value ()); + } - void assign (const idx_vector& i, const idx_vector& j, const Array& rhs, - const T& rfv = resize_fill_value ()); + void assign (const idx_vector& i, const idx_vector& j, const Array& rhs, const T& rfv); + void assign (const idx_vector& i, const idx_vector& j, const Array& rhs) + { + assign (i, j, rhs, resize_fill_value ()); + } - void assign (const Array& ia, const Array& rhs, - const T& rfv = resize_fill_value ()); + void assign (const Array& ia, const Array& rhs, const T& rfv); + void assign (const Array& ia, const Array& rhs) + { + assign (ia, rhs, resize_fill_value ()); + } // Deleting elements. @@ -672,8 +695,11 @@ private: - void resize2 (octave_idx_type nr, octave_idx_type nc, - const T& rfv = resize_fill_value ()); + void resize2 (octave_idx_type nr, octave_idx_type nc, const T& rfv); + void resize2 (octave_idx_type nr, octave_idx_type nc) + { + resize2 (nr, nc, resize_fill_value ()); + } static void instantiation_guard (); }; diff -r 88e67d58b06b -r 13cc11418393 liboctave/CColVector.h --- a/liboctave/CColVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/CColVector.h Thu May 10 16:31:02 2012 -0400 @@ -132,8 +132,7 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexColumnVector& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexColumnVector& a); - void resize (octave_idx_type n, - const Complex& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const Complex& rfv = Complex (0)) { Array::resize (dim_vector (n, 1), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/CMatrix.h --- a/liboctave/CMatrix.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/CMatrix.h Thu May 10 16:31:02 2012 -0400 @@ -152,7 +152,7 @@ ComplexColumnVector column (octave_idx_type i) const; void resize (octave_idx_type nr, octave_idx_type nc, - const Complex& rfv = resize_fill_value ()) + const Complex& rfv = Complex (0)) { MArray::resize (dim_vector (nr, nc), rfv); } @@ -378,9 +378,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexMatrix& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexMatrix& a); - - static Complex resize_fill_value (void) { return Complex (0.0, 0.0); } - }; extern OCTAVE_API ComplexMatrix conj (const ComplexMatrix& a); diff -r 88e67d58b06b -r 13cc11418393 liboctave/CNDArray.h --- a/liboctave/CNDArray.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/CNDArray.h Thu May 10 16:31:02 2012 -0400 @@ -135,8 +135,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexNDArray& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexNDArray& a); - static Complex resize_fill_value (void) { return Complex (0.0, 0.0); } - // bool all_elements_are_real (void) const; // bool all_integers (double& max_val, double& min_val) const; diff -r 88e67d58b06b -r 13cc11418393 liboctave/CRowVector.h --- a/liboctave/CRowVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/CRowVector.h Thu May 10 16:31:02 2012 -0400 @@ -112,8 +112,7 @@ friend std::ostream& operator << (std::ostream& os, const ComplexRowVector& a); friend std::istream& operator >> (std::istream& is, ComplexRowVector& a); - void resize (octave_idx_type n, - const Complex& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const Complex& rfv = Complex (0)) { Array::resize (dim_vector (1, n), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/DiagArray2.h --- a/liboctave/DiagArray2.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/DiagArray2.h Thu May 10 16:31:02 2012 -0400 @@ -150,8 +150,11 @@ T dgxelem (octave_idx_type i) const { return Array::xelem (i); } - void resize (octave_idx_type n, octave_idx_type m, - const T& rfv = Array::resize_fill_value ()); + void resize (octave_idx_type n, octave_idx_type m, const T& rfv); + void resize (octave_idx_type n, octave_idx_type m) + { + resize (n, m, Array::resize_fill_value ()); + } DiagArray2 transpose (void) const; DiagArray2 hermitian (T (*fcn) (const T&) = 0) const; diff -r 88e67d58b06b -r 13cc11418393 liboctave/boolMatrix.h --- a/liboctave/boolMatrix.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/boolMatrix.h Thu May 10 16:31:02 2012 -0400 @@ -84,14 +84,10 @@ friend std::istream& operator >> (std::istream& is, Matrix& a); #endif - void resize (octave_idx_type nr, octave_idx_type nc, - bool rfv = resize_fill_value ()) + void resize (octave_idx_type nr, octave_idx_type nc, bool rfv = false) { Array::resize (dim_vector (nr, nc), rfv); } - - static bool resize_fill_value (void) { return false; } - }; MM_BOOL_OP_DECLS (boolMatrix, boolMatrix, OCTAVE_API) diff -r 88e67d58b06b -r 13cc11418393 liboctave/boolNDArray.h --- a/liboctave/boolNDArray.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/boolNDArray.h Thu May 10 16:31:02 2012 -0400 @@ -96,8 +96,6 @@ // friend std::ostream& operator << (std::ostream& os, const NDArray& a); // friend std::istream& operator >> (std::istream& is, NDArray& a); - static bool resize_fill_value (void) { return false; } - // bool all_elements_are_real (void) const; // bool all_integers (double& max_val, double& min_val) const; diff -r 88e67d58b06b -r 13cc11418393 liboctave/chMatrix.h --- a/liboctave/chMatrix.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/chMatrix.h Thu May 10 16:31:02 2012 -0400 @@ -86,8 +86,7 @@ charMatrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; - void resize (octave_idx_type nr, octave_idx_type nc, - char rfv = resize_fill_value ()) + void resize (octave_idx_type nr, octave_idx_type nc, char rfv = 0) { Array::resize (dim_vector (nr, nc), rfv); } @@ -103,9 +102,6 @@ friend std::ostream& operator << (std::ostream& os, const Matrix& a); friend std::istream& operator >> (std::istream& is, Matrix& a); #endif - - static char resize_fill_value (void) { return '\0'; } - }; MS_CMP_OP_DECLS (charMatrix, char, OCTAVE_API) diff -r 88e67d58b06b -r 13cc11418393 liboctave/chNDArray.h --- a/liboctave/chNDArray.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/chNDArray.h Thu May 10 16:31:02 2012 -0400 @@ -92,8 +92,6 @@ // friend std::ostream& operator << (std::ostream& os, const charNDArray& a); // friend std::istream& operator >> (std::istream& is, charNDArray& a); - static char resize_fill_value (void) { return '\0'; } - charNDArray diag (octave_idx_type k = 0) const; charNDArray diag (octave_idx_type m, octave_idx_type n) const; diff -r 88e67d58b06b -r 13cc11418393 liboctave/dColVector.h --- a/liboctave/dColVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/dColVector.h Thu May 10 16:31:02 2012 -0400 @@ -99,8 +99,7 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ColumnVector& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, ColumnVector& a); - void resize (octave_idx_type n, - const double& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const double& rfv = 0) { Array::resize (dim_vector (n, 1), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/dMatrix.h --- a/liboctave/dMatrix.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/dMatrix.h Thu May 10 16:31:02 2012 -0400 @@ -125,8 +125,7 @@ ColumnVector column (octave_idx_type i) const; - void resize (octave_idx_type nr, octave_idx_type nc, - double rfv = resize_fill_value ()) + void resize (octave_idx_type nr, octave_idx_type nc, double rfv = 0) { MArray::resize (dim_vector (nr, nc), rfv); } @@ -334,8 +333,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const Matrix& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, Matrix& a); - - static double resize_fill_value (void) { return 0; } }; // Publish externally used friend functions. diff -r 88e67d58b06b -r 13cc11418393 liboctave/dNDArray.h --- a/liboctave/dNDArray.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/dNDArray.h Thu May 10 16:31:02 2012 -0400 @@ -150,8 +150,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const NDArray& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, NDArray& a); - static double resize_fill_value (void) { return 0; } - NDArray diag (octave_idx_type k = 0) const; NDArray diag (octave_idx_type m, octave_idx_type n) const; diff -r 88e67d58b06b -r 13cc11418393 liboctave/dRowVector.h --- a/liboctave/dRowVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/dRowVector.h Thu May 10 16:31:02 2012 -0400 @@ -92,8 +92,7 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const RowVector& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, RowVector& a); - void resize (octave_idx_type n, - const double& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const double& rfv = 0) { Array::resize (dim_vector (1, n), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/fCColVector.h --- a/liboctave/fCColVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fCColVector.h Thu May 10 16:31:02 2012 -0400 @@ -134,8 +134,7 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatComplexColumnVector& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatComplexColumnVector& a); - void resize (octave_idx_type n, - const FloatComplex& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const FloatComplex& rfv = FloatComplex (0)) { Array::resize (dim_vector (n, 1), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/fCMatrix.h --- a/liboctave/fCMatrix.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fCMatrix.h Thu May 10 16:31:02 2012 -0400 @@ -157,7 +157,7 @@ FloatComplexColumnVector column (octave_idx_type i) const; void resize (octave_idx_type nr, octave_idx_type nc, - const FloatComplex& rfv = resize_fill_value ()) + const FloatComplex& rfv = FloatComplex (0)) { MArray::resize (dim_vector (nr, nc), rfv); } @@ -383,9 +383,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatComplexMatrix& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatComplexMatrix& a); - - static FloatComplex resize_fill_value (void) { return FloatComplex (0.0, 0.0); } - }; extern OCTAVE_API FloatComplexMatrix conj (const FloatComplexMatrix& a); diff -r 88e67d58b06b -r 13cc11418393 liboctave/fCNDArray.h --- a/liboctave/fCNDArray.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fCNDArray.h Thu May 10 16:31:02 2012 -0400 @@ -135,8 +135,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatComplexNDArray& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatComplexNDArray& a); - static FloatComplex resize_fill_value (void) { return FloatComplex (0.0, 0.0); } - // bool all_elements_are_real (void) const; // bool all_integers (float& max_val, float& min_val) const; diff -r 88e67d58b06b -r 13cc11418393 liboctave/fCRowVector.h --- a/liboctave/fCRowVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fCRowVector.h Thu May 10 16:31:02 2012 -0400 @@ -116,8 +116,7 @@ friend std::ostream& operator << (std::ostream& os, const FloatComplexRowVector& a); friend std::istream& operator >> (std::istream& is, FloatComplexRowVector& a); - void resize (octave_idx_type n, - const FloatComplex& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const FloatComplex& rfv = FloatComplex (0)) { Array::resize (dim_vector (1, n), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/fColVector.h --- a/liboctave/fColVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fColVector.h Thu May 10 16:31:02 2012 -0400 @@ -102,8 +102,7 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatColumnVector& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatColumnVector& a); - void resize (octave_idx_type n, - const float& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const float& rfv = 0) { Array::resize (dim_vector (n, 1), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/fMatrix.h --- a/liboctave/fMatrix.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fMatrix.h Thu May 10 16:31:02 2012 -0400 @@ -126,8 +126,7 @@ FloatColumnVector column (octave_idx_type i) const; - void resize (octave_idx_type nr, octave_idx_type nc, - float rfv = resize_fill_value ()) + void resize (octave_idx_type nr, octave_idx_type nc, float rfv = 0) { MArray::resize (dim_vector (nr, nc), rfv); } @@ -334,9 +333,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatMatrix& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatMatrix& a); - - static float resize_fill_value (void) { return 0; } - }; // Publish externally used friend functions. diff -r 88e67d58b06b -r 13cc11418393 liboctave/fNDArray.h --- a/liboctave/fNDArray.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fNDArray.h Thu May 10 16:31:02 2012 -0400 @@ -147,8 +147,6 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatNDArray& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatNDArray& a); - static float resize_fill_value (void) { return 0; } - FloatNDArray diag (octave_idx_type k = 0) const; FloatNDArray diag (octave_idx_type m, octave_idx_type n) const; diff -r 88e67d58b06b -r 13cc11418393 liboctave/fRowVector.h --- a/liboctave/fRowVector.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/fRowVector.h Thu May 10 16:31:02 2012 -0400 @@ -93,8 +93,7 @@ friend OCTAVE_API std::ostream& operator << (std::ostream& os, const FloatRowVector& a); friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatRowVector& a); - void resize (octave_idx_type n, - const float& rfv = Array::resize_fill_value ()) + void resize (octave_idx_type n, const float& rfv = 0) { Array::resize (dim_vector (1, n), rfv); } diff -r 88e67d58b06b -r 13cc11418393 liboctave/intNDArray.h --- a/liboctave/intNDArray.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/intNDArray.h Thu May 10 16:31:02 2012 -0400 @@ -115,9 +115,6 @@ static octave_idx_type compute_index (Array& ra_idx, const dim_vector& dimensions); - - static T resize_fill_value (void) { return 0; } - }; // i/o diff -r 88e67d58b06b -r 13cc11418393 liboctave/str-vec.h --- a/liboctave/str-vec.h Thu May 10 11:48:48 2012 -0400 +++ b/liboctave/str-vec.h Thu May 10 16:31:02 2012 -0400 @@ -88,7 +88,7 @@ return longest; } - void resize (octave_idx_type n, const std::string& rfv = resize_fill_value ()) + void resize (octave_idx_type n, const std::string& rfv = std::string ()) { Array::resize (dim_vector (n, 1), rfv); } diff -r 88e67d58b06b -r 13cc11418393 src/Cell.cc --- a/src/Cell.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/Cell.cc Thu May 10 16:31:02 2012 -0400 @@ -97,7 +97,7 @@ // SV as possible. Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim) - : Array (dv, resize_fill_value ()) + : Array (dv, Matrix ()) { octave_idx_type n = sv.length (); @@ -173,8 +173,7 @@ idx_vector i = idx_arg(0).index_vector (); if (! error_state) - retval = Array::index (i, resize_ok, - resize_fill_value ()); + retval = Array::index (i, resize_ok, Matrix ()); } break; @@ -187,8 +186,7 @@ idx_vector j = idx_arg(1).index_vector (); if (! error_state) - retval = Array::index (i, j, resize_ok, - resize_fill_value ()); + retval = Array::index (i, j, resize_ok, Matrix ()); } } break; @@ -206,8 +204,7 @@ } if (!error_state) - retval = Array::index (iv, resize_ok, - resize_fill_value ()); + retval = Array::index (iv, resize_ok, Matrix ()); } break; } diff -r 88e67d58b06b -r 13cc11418393 src/Cell.h --- a/src/Cell.h Thu May 10 11:48:48 2012 -0400 +++ b/src/Cell.h Thu May 10 16:31:02 2012 -0400 @@ -48,10 +48,10 @@ Cell (const octave_value_list& ovl); Cell (octave_idx_type n, octave_idx_type m, - const octave_value& val = resize_fill_value ()) + const octave_value& val = Matrix ()) : Array (dim_vector (n, m), val) { } - Cell (const dim_vector& dv, const octave_value& val = resize_fill_value ()) + Cell (const dim_vector& dv, const octave_value& val = Matrix ()) : Array (dv, val) { } Cell (const Array& c) @@ -86,7 +86,7 @@ using Array::assign; void assign (const octave_value_list& idx, const Cell& rhs, - const octave_value& fill_val = resize_fill_value ()); + const octave_value& fill_val = Matrix ()); Cell reshape (const dim_vector& new_dims) const { return Array::reshape (new_dims); } @@ -110,7 +110,11 @@ bool any_element_is_nan (void) const { return false; } bool is_true (void) const { return false; } - static octave_value resize_fill_value (void) { return Matrix (); } + octave_value resize_fill_value (void) const + { + static Matrix rfv; + return rfv; + } Cell diag (octave_idx_type k = 0) const; diff -r 88e67d58b06b -r 13cc11418393 src/oct-map.cc --- a/src/oct-map.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/oct-map.cc Thu May 10 16:31:02 2012 -0400 @@ -557,7 +557,7 @@ for (octave_idx_type i = 0; i < nf; i++) { if (fill) - xvals[i].resize (dv, Cell::resize_fill_value ()); + xvals[i].resize (dv, Matrix ()); else xvals[i].resize (dv); } @@ -1160,7 +1160,7 @@ for (octave_idx_type i = 0; i < nf; i++) { if (&xvals[i] != &ref) - xvals[i].resize (dimensions, Cell::resize_fill_value ()); + xvals[i].resize (dimensions, Matrix ()); } optimize_dimensions (); @@ -1489,7 +1489,7 @@ Cell tmp = contents(p); if (fill) - tmp.resize (dv, Cell::resize_fill_value ()); + tmp.resize (dv, Matrix ()); else tmp.resize (dv); @@ -1669,7 +1669,7 @@ if (tmp_dims != dimensions) { for (iterator p = begin (); p != end (); p++) - contents(p).resize (tmp_dims, Cell::resize_fill_value ()); + contents(p).resize (tmp_dims, Matrix ()); dimensions = tmp_dims; } diff -r 88e67d58b06b -r 13cc11418393 src/oct-obj.h --- a/src/oct-obj.h Thu May 10 11:48:48 2012 -0400 +++ b/src/oct-obj.h Thu May 10 16:31:02 2012 -0400 @@ -91,8 +91,7 @@ bool empty (void) const { return length () == 0; } - void resize (octave_idx_type n, const octave_value& rfv - = Array::resize_fill_value ()) + void resize (octave_idx_type n, const octave_value& rfv = octave_value ()) { data.resize (dim_vector (1, n), rfv); } diff -r 88e67d58b06b -r 13cc11418393 src/ov-complex.cc --- a/src/ov-complex.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/ov-complex.cc Thu May 10 16:31:02 2012 -0400 @@ -225,7 +225,7 @@ { if (fill) { - ComplexNDArray retval (dv, ComplexNDArray::resize_fill_value ()); + ComplexNDArray retval (dv, Complex (0)); if (dv.numel ()) retval(0) = scalar; diff -r 88e67d58b06b -r 13cc11418393 src/ov-float.cc --- a/src/ov-float.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/ov-float.cc Thu May 10 16:31:02 2012 -0400 @@ -79,7 +79,7 @@ { if (fill) { - FloatNDArray retval (dv, NDArray::resize_fill_value()); + FloatNDArray retval (dv, 0); if (dv.numel ()) retval(0) = scalar; diff -r 88e67d58b06b -r 13cc11418393 src/ov-flt-complex.cc --- a/src/ov-flt-complex.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/ov-flt-complex.cc Thu May 10 16:31:02 2012 -0400 @@ -210,7 +210,7 @@ { if (fill) { - FloatComplexNDArray retval (dv, FloatComplexNDArray::resize_fill_value ()); + FloatComplexNDArray retval (dv, FloatComplex (0)); if (dv.numel ()) retval(0) = scalar; diff -r 88e67d58b06b -r 13cc11418393 src/ov-range.cc --- a/src/ov-range.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/ov-range.cc Thu May 10 16:31:02 2012 -0400 @@ -335,7 +335,7 @@ { NDArray retval = array_value (); if (fill) - retval.resize (dv, NDArray::resize_fill_value ()); + retval.resize (dv, 0); else retval.resize (dv); return retval; diff -r 88e67d58b06b -r 13cc11418393 src/ov-scalar.cc --- a/src/ov-scalar.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/ov-scalar.cc Thu May 10 16:31:02 2012 -0400 @@ -94,7 +94,7 @@ { if (fill) { - NDArray retval (dv, NDArray::resize_fill_value()); + NDArray retval (dv, 0); if (dv.numel ()) retval(0) = scalar; diff -r 88e67d58b06b -r 13cc11418393 src/ov-str-mat.cc --- a/src/ov-str-mat.cc Thu May 10 11:48:48 2012 -0400 +++ b/src/ov-str-mat.cc Thu May 10 16:31:02 2012 -0400 @@ -143,7 +143,7 @@ { charNDArray retval (matrix); if (fill) - retval.resize (dv, charNDArray::resize_fill_value ()); + retval.resize (dv, 0); else retval.resize (dv); return octave_value (retval, is_sq_string () ? '\'' : '"');