# HG changeset patch # User Jaroslav Hajek # Date 1266937947 -3600 # Node ID a3635bc1ea19c34cf6010b2d9fd14660b3d4c456 # Parent 5150ceb4dbb4d10dd019c68f131019745ddd8cac remove Array2 diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-C.cc --- a/liboctave/Array-C.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-C.cc Tue Feb 23 16:12:27 2010 +0100 @@ -92,10 +92,6 @@ INSTANTIATE_ARRAY (Complex, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); #include "DiagArray2.h" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-b.cc --- a/liboctave/Array-b.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-b.cc Tue Feb 23 16:12:27 2010 +0100 @@ -108,10 +108,6 @@ INSTANTIATE_ARRAY (bool, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); #include "DiagArray2.h" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-ch.cc --- a/liboctave/Array-ch.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-ch.cc Tue Feb 23 16:12:27 2010 +0100 @@ -35,10 +35,6 @@ INSTANTIATE_ARRAY (char, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); #include "DiagArray2.h" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-d.cc --- a/liboctave/Array-d.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-d.cc Tue Feb 23 16:12:27 2010 +0100 @@ -159,10 +159,6 @@ INSTANTIATE_ARRAY (double, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); #include "DiagArray2.h" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-f.cc --- a/liboctave/Array-f.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-f.cc Tue Feb 23 16:12:27 2010 +0100 @@ -159,10 +159,6 @@ INSTANTIATE_ARRAY (float, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); #include "DiagArray2.h" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-fC.cc --- a/liboctave/Array-fC.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-fC.cc Tue Feb 23 16:12:27 2010 +0100 @@ -93,10 +93,6 @@ INSTANTIATE_ARRAY (FloatComplex, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); #include "DiagArray2.h" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-i.cc --- a/liboctave/Array-i.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-i.cc Tue Feb 23 16:12:27 2010 +0100 @@ -68,10 +68,6 @@ INSTANTIATE_ARRAY (octave_uint32, OCTAVE_API); INSTANTIATE_ARRAY (octave_uint64, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - #include "DiagArray2.h" #include "DiagArray2.cc" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-s.cc --- a/liboctave/Array-s.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-s.cc Tue Feb 23 16:12:27 2010 +0100 @@ -38,10 +38,6 @@ INSTANTIATE_ARRAY (short, OCTAVE_API); -#include "Array2.h" - -template class Array2; - #include "DiagArray2.h" #include "DiagArray2.cc" diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array-voidp.cc --- a/liboctave/Array-voidp.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array-voidp.cc Tue Feb 23 16:12:27 2010 +0100 @@ -35,10 +35,6 @@ INSTANTIATE_ARRAY (void *, OCTAVE_API); -#include "Array2.h" - -template class OCTAVE_API Array2; - #include "Array3.h" template class OCTAVE_API Array3; diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array.cc --- a/liboctave/Array.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array.cc Tue Feb 23 16:12:27 2010 +0100 @@ -51,10 +51,31 @@ : rep (a.rep), dimensions (dv), slice_data (a.slice_data), slice_len (a.slice_len) { - if (dv.numel () != a.numel ()) + if (dimensions.safe_numel () != a.numel ()) { - std::string dimensions_str = dimensions.str (); - std::string new_dims_str = dv.str (); + std::string dimensions_str = a.dimensions.str (); + std::string new_dims_str = dimensions.str (); + + (*current_liboctave_error_handler) + ("reshape: can't reshape %s array to %s array", + dimensions_str.c_str (), new_dims_str.c_str ()); + } + + // This goes here because if an exception is thrown by the above, + // destructor will be never called. + rep->count++; + dimensions.chop_trailing_singletons (); +} + +template +Array::Array (const Array& a, octave_idx_type nr, octave_idx_type nc) + : rep (a.rep), dimensions (nr, nc), + slice_data (a.slice_data), slice_len (a.slice_len) +{ + if (dimensions.safe_numel () != a.numel ()) + { + std::string dimensions_str = a.dimensions.str (); + std::string new_dims_str = dimensions.str (); (*current_liboctave_error_handler) ("reshape: can't reshape %s array to %s array", diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array.h --- a/liboctave/Array.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array.h Tue Feb 23 16:12:27 2010 +0100 @@ -244,6 +244,8 @@ // Reshape constructor. Array (const Array& a, const dim_vector& dv); + Array (const Array& a, octave_idx_type nr, octave_idx_type nc); + // Type conversion case. template Array (const Array& a) @@ -513,6 +515,9 @@ // Must be 0 <= lo && up <= numel. May be up < lo. Array linear_slice (octave_idx_type lo, octave_idx_type up) const; + Array reshape (octave_idx_type nr, octave_idx_type nc) const + { return Array (*this, nr, nc); } + Array reshape (const dim_vector& new_dims) const { return Array (*this, new_dims); } diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Array2.h --- a/liboctave/Array2.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Array2.h Tue Feb 23 16:12:27 2010 +0100 @@ -25,137 +25,12 @@ #if !defined (octave_Array2_h) #define octave_Array2_h 1 -#include -#include -#include - #include "Array.h" -#include "lo-error.h" -#include "lo-math.h" - -class idx_vector; - -// Two dimensional array class. - -template -class -Array2 : public Array -{ -protected: - - Array2 (T *d, octave_idx_type r, octave_idx_type c) : Array (d, dim_vector (r, c)) { } - -public: - - Array2 (void) : Array (dim_vector (0, 0)) { } - - Array2 (octave_idx_type r, octave_idx_type c) : Array (dim_vector (r, c)) { } - - Array2 (octave_idx_type r, octave_idx_type c, const T& val) - : Array (dim_vector (r, c), val) { } - - Array2 (const dim_vector& dv) : Array (dv) - { - if (dv.length () != 2) - (*current_liboctave_error_handler) ("too many dimensions"); - } - - Array2 (const dim_vector& dv, const T& val) : Array (dv) - { - if (dv.length () != 2) - (*current_liboctave_error_handler) ("too many dimensions"); - else - Array::fill (val); - } - - Array2 (const Array2& a) : Array (a, a.dims ()) { } - - Array2 (const Array& a, octave_idx_type r, octave_idx_type c) - : Array (a, dim_vector (r, c)) { } - - template - Array2 (const Array& a) : Array (a) { } - - template - Array2 (const Array& a, const dim_vector& dv) - : Array (a, dv) { } - - ~Array2 (void) { } - - Array2& operator = (const Array2& a) - { - if (this != &a) - Array::operator = (a); - - return *this; - } +#define Array2 Array - void resize (octave_idx_type r, octave_idx_type c) - { Array::resize (r, c, Array::resize_fill_value ()); } - - void resize (octave_idx_type r, octave_idx_type c, const T& val) - { Array::resize (r, c, val); } - - Array2& insert (const Array2& a, octave_idx_type r, octave_idx_type c) - { - Array::insert (a, r, c); - return *this; - } - - Array2 transpose (void) const - { - Array tmp = Array::transpose (); - return Array2 (tmp, tmp.rows (), tmp.columns ()); - } - - Array2 hermitian (T (*fcn) (const T&) = 0) const - { - Array tmp = Array::hermitian (fcn); - return Array2 (tmp, tmp.rows (), tmp.columns ()); - } - - Array2 index (const idx_vector& i, bool resize_ok = false, - const T& rfv = Array::resize_fill_value ()) const - { - Array tmp = Array::index (i, resize_ok, rfv); - return Array2 (tmp, tmp.rows (), tmp.columns ()); - } - - Array2 index (const idx_vector& i, const idx_vector& j, bool resize_ok = false, - const T& rfv = Array::resize_fill_value ()) const - { - Array tmp = Array::index (i, j, resize_ok, rfv); - return Array2 (tmp, tmp.rows (), tmp.columns ()); - } - - Array2 sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const - { - Array tmp = Array::sort (dim, mode); - return Array2 (tmp, tmp.rows (), tmp.columns ()); - } - - Array2 sort (Array &sidx, octave_idx_type dim = 0, - sortmode mode = ASCENDING) const - { - Array tmp = Array::sort (sidx, dim, mode); - return Array2 (tmp, tmp.rows (), tmp.columns ()); - } - - Array2 diag (octave_idx_type k) const - { - return Array::diag (k); - } - - // FIXME: should go away. - template - Array2 - map (U (&fcn) (T)) const - { return Array::template map (fcn); } - - template - Array2 - map (U (&fcn) (const T&)) const - { return Array::template map (fcn); } -}; +// If we're with GNU C++, issue a warning. +#ifdef __GNUC__ +#warning Using Array2 is deprecated. Use Array directly. +#endif #endif diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/CMatrix.cc --- a/liboctave/CMatrix.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/CMatrix.cc Tue Feb 23 16:12:27 2010 +0100 @@ -2394,7 +2394,8 @@ { ComplexMatrix tmp (b); - return solve (typ, tmp, info, rcon, sing_handler, transt).column(static_cast (0)); + tmp = solve (typ, tmp, info, rcon, sing_handler, true, transt); + return tmp.column(static_cast (0)); } ComplexMatrix diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/CMatrix.h --- a/liboctave/CMatrix.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/CMatrix.h Tue Feb 23 16:12:27 2010 +0100 @@ -24,7 +24,6 @@ #if !defined (octave_ComplexMatrix_h) #define octave_ComplexMatrix_h 1 -#include "Array2.h" #include "MArray.h" #include "MDiagArray2.h" #include "MatrixType.h" @@ -63,9 +62,6 @@ ComplexMatrix (const MArray& a) : MArray (a.as_matrix ()) { } template - ComplexMatrix (const Array2& a) : MArray (a) { } - - template ComplexMatrix (const Array& a) : MArray (a.as_matrix ()) { } ComplexMatrix (const Matrix& re, const Matrix& im); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/CNDArray.cc --- a/liboctave/CNDArray.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/CNDArray.cc Tue Feb 23 16:12:27 2010 +0100 @@ -847,7 +847,7 @@ ComplexMatrix retval; if (ndims () == 2) - retval = ComplexMatrix (Array2 (*this)); + retval = ComplexMatrix (Array (*this)); else (*current_liboctave_error_handler) ("invalid conversion of ComplexNDArray to ComplexMatrix"); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/ChangeLog --- a/liboctave/ChangeLog Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/ChangeLog Tue Feb 23 16:12:27 2010 +0100 @@ -1,3 +1,45 @@ +2010-02-24 Jaroslav Hajek + + * Array.cc (Array::Array (const Array&, octave_idx_type, + octave_idx_type): New ctor. + (Array::reshape (octave_idx_type, octave_idx_type): New method. + * Array.h: Declare them. + * Array2.h: Deprecate Array2, make it a #define for Array. + + * Array-C.cc: Remove Array2 instantiation. + * Array-b.cc: Ditto. + * Array-ch.cc: Ditto. + * Array-d.cc: Ditto. + * Array-f.cc: Ditto. + * Array-fC.cc: Ditto. + * Array-i.cc: Ditto. + * Array-s.cc: Ditto. + * Array-voidp.cc: Ditto. + + * CMatrix.cc: Use Array instead of Array2 everywhere. + * CMatrix.h: Ditto. + * CNDArray.cc: Ditto. + * DiagArray2.cc: Ditto. + * DiagArray2.h: Ditto. + * MDiagArray2.h: Ditto. + * Sparse.cc: Ditto. + * Sparse.h: Ditto. + * boolMatrix.h: Ditto. + * boolNDArray.cc: Ditto. + * chMatrix.h: Ditto. + * chNDArray.cc: Ditto. + * dMatrix.cc: Ditto. + * dMatrix.h: Ditto. + * dNDArray.cc: Ditto. + * fCMatrix.cc: Ditto. + * fCMatrix.h: Ditto. + * fCNDArray.cc: Ditto. + * fMatrix.cc: Ditto. + * fMatrix.h: Ditto. + * fNDArray.cc: Ditto. + * lo-specfun.cc: Ditto. + * lo-specfun.h: Ditto. + 2010-02-23 Jaroslav Hajek * chMatrix.h (charMatrix): Base on Array. diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/DiagArray2.cc --- a/liboctave/DiagArray2.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/DiagArray2.cc Tue Feb 23 16:12:27 2010 +0100 @@ -152,9 +152,9 @@ } template -DiagArray2::operator Array2 (void) const +DiagArray2::operator Array (void) const { - Array2 result (dim1 (), dim2 ()); + Array result (dim1 (), dim2 ()); for (octave_idx_type i = 0, len = length (); i < len; i++) result.xelem (i, i) = dgelem (i); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/DiagArray2.h --- a/liboctave/DiagArray2.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/DiagArray2.h Tue Feb 23 16:12:27 2010 +0100 @@ -30,7 +30,6 @@ #include #include "Array.h" -#include "Array2.h" #include "lo-error.h" // A two-dimensional array with diagonal elements only. @@ -219,7 +218,7 @@ DiagArray2 transpose (void) const; DiagArray2 hermitian (T (*fcn) (const T&) = 0) const; - operator Array2 (void) const; + operator Array (void) const; const T *data (void) const { return Array::data (); } diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/MDiagArray2.h --- a/liboctave/MDiagArray2.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/MDiagArray2.h Tue Feb 23 16:12:27 2010 +0100 @@ -73,7 +73,7 @@ operator MArray () const { - return DiagArray2::operator Array2 (); + return DiagArray2::operator Array (); } octave_idx_type nnz (void) const diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Sparse.cc --- a/liboctave/Sparse.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Sparse.cc Tue Feb 23 16:12:27 2010 +0100 @@ -549,36 +549,6 @@ } template -Sparse::Sparse (const Array2& a) - : dimensions (a.dims ()), idx (0), idx_count (0) -{ - octave_idx_type nr = rows (); - octave_idx_type nc = cols (); - octave_idx_type len = a.length (); - octave_idx_type new_nzmx = 0; - - // First count the number of non-zero terms - for (octave_idx_type i = 0; i < len; i++) - if (a(i) != T ()) - new_nzmx++; - - rep = new typename Sparse::SparseRep (nr, nc, new_nzmx); - - octave_idx_type ii = 0; - xcidx(0) = 0; - for (octave_idx_type j = 0; j < nc; j++) - { - for (octave_idx_type i = 0; i < nr; i++) - if (a.elem (i,j) != T ()) - { - xdata(ii) = a.elem (i,j); - xridx(ii++) = i; - } - xcidx(j+1) = ii; - } -} - -template Sparse::Sparse (const Array& a) : dimensions (a.dims ()), idx (0), idx_count (0) { diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/Sparse.h --- a/liboctave/Sparse.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/Sparse.h Tue Feb 23 16:12:27 2010 +0100 @@ -31,7 +31,6 @@ #include #include "Array.h" -#include "Array2.h" #include "dim-vector.h" #include "lo-error.h" #include "lo-utils.h" @@ -224,7 +223,6 @@ octave_idx_type nr, octave_idx_type nc, bool sum_terms); // Sparsify a normal matrix - Sparse (const Array2& a); Sparse (const Array& a); virtual ~Sparse (void); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/boolMatrix.h --- a/liboctave/boolMatrix.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/boolMatrix.h Tue Feb 23 16:12:27 2010 +0100 @@ -40,7 +40,7 @@ boolMatrix (octave_idx_type r, octave_idx_type c, bool val) : Array (r, c, val) { } boolMatrix (const dim_vector& dv) : Array (dv) { } boolMatrix (const dim_vector& dv, bool val) : Array (dv, val) { } - boolMatrix (const Array& a) : Array (a) { } + boolMatrix (const Array& a) : Array (a.as_matrix ()) { } boolMatrix (const boolMatrix& a) : Array (a) { } boolMatrix& operator = (const boolMatrix& a) diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/boolNDArray.cc --- a/liboctave/boolNDArray.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/boolNDArray.cc Tue Feb 23 16:12:27 2010 +0100 @@ -111,28 +111,7 @@ boolMatrix boolNDArray::matrix_value (void) const { - boolMatrix retval; - - int nd = ndims (); - - switch (nd) - { - case 1: - retval = boolMatrix (Array2 (*this, dimensions(0), 1)); - break; - - case 2: - retval = boolMatrix (Array2 (*this, dimensions(0), - dimensions(1))); - break; - - default: - (*current_liboctave_error_handler) - ("invalid conversion of boolNDArray to boolMatrix"); - break; - } - - return retval; + return *this; } void diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/chMatrix.h --- a/liboctave/chMatrix.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/chMatrix.h Tue Feb 23 16:12:27 2010 +0100 @@ -45,7 +45,7 @@ charMatrix (octave_idx_type r, octave_idx_type c, char val) : Array (r, c, val) { } charMatrix (const dim_vector& dv) : Array (dv) { } charMatrix (const dim_vector& dv, char val) : Array (dv, val) { } - charMatrix (const Array& a) : Array (a) { } + charMatrix (const Array& a) : Array (a.as_matrix ()) { } charMatrix (const charMatrix& a) : Array (a) { } charMatrix (char c); charMatrix (const char *s); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/chNDArray.cc --- a/liboctave/chNDArray.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/chNDArray.cc Tue Feb 23 16:12:27 2010 +0100 @@ -109,28 +109,7 @@ charMatrix charNDArray::matrix_value (void) const { - charMatrix retval; - - int nd = ndims (); - - switch (nd) - { - case 1: - retval = charMatrix (Array2 (*this, dimensions(0), 1)); - break; - - case 2: - retval = charMatrix (Array2 (*this, dimensions(0), - dimensions(1))); - break; - - default: - (*current_liboctave_error_handler) - ("invalid conversion of charNDArray to charMatrix"); - break; - } - - return retval; + return *this; } void diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/dMatrix.cc --- a/liboctave/dMatrix.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/dMatrix.cc Tue Feb 23 16:12:27 2010 +0100 @@ -2050,7 +2050,8 @@ double& rcon, solve_singularity_handler sing_handler, blas_trans_type transt) const { Matrix tmp (b); - return solve (typ, tmp, info, rcon, sing_handler, transt).column(static_cast (0)); + tmp = solve (typ, tmp, info, rcon, sing_handler, true, transt); + return tmp.column(static_cast (0)); } ComplexColumnVector diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/dMatrix.h --- a/liboctave/dMatrix.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/dMatrix.h Tue Feb 23 16:12:27 2010 +0100 @@ -25,7 +25,6 @@ #define octave_Matrix_int_h 1 #include "MArray.h" -#include "Array2.h" #include "MDiagArray2.h" #include "MatrixType.h" @@ -60,9 +59,6 @@ Matrix (const MArray& a) : MArray (a.as_matrix ()) { } template - Matrix (const Array2& a) : MArray (a) { } - - template Matrix (const Array& a) : MArray (a.as_matrix ()) { } explicit Matrix (const RowVector& rv); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/dNDArray.cc --- a/liboctave/dNDArray.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/dNDArray.cc Tue Feb 23 16:12:27 2010 +0100 @@ -914,7 +914,7 @@ Matrix retval; if (ndims () == 2) - retval = Matrix (Array2 (*this)); + retval = Matrix (Array (*this)); else (*current_liboctave_error_handler) ("invalid conversion of NDArray to Matrix"); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/fCMatrix.cc --- a/liboctave/fCMatrix.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/fCMatrix.cc Tue Feb 23 16:12:27 2010 +0100 @@ -2387,7 +2387,8 @@ { FloatComplexMatrix tmp (b); - return solve (typ, tmp, info, rcon, sing_handler, transt).column(static_cast (0)); + tmp = solve (typ, tmp, info, rcon, sing_handler, true, transt); + return tmp.column(static_cast (0)); } FloatComplexMatrix diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/fCMatrix.h --- a/liboctave/fCMatrix.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/fCMatrix.h Tue Feb 23 16:12:27 2010 +0100 @@ -62,9 +62,6 @@ FloatComplexMatrix (const MArray& a) : MArray (a.as_matrix ()) { } template - FloatComplexMatrix (const Array2& a) : MArray (a) { } - - template FloatComplexMatrix (const Array& a) : MArray (a.as_matrix ()) { } explicit FloatComplexMatrix (const FloatMatrix& a); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/fCNDArray.cc --- a/liboctave/fCNDArray.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/fCNDArray.cc Tue Feb 23 16:12:27 2010 +0100 @@ -842,7 +842,7 @@ FloatComplexMatrix retval; if (ndims () == 2) - retval = FloatComplexMatrix (Array2 (*this)); + retval = FloatComplexMatrix (Array (*this)); else (*current_liboctave_error_handler) ("invalid conversion of FloatComplexNDArray to FloatComplexMatrix"); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/fMatrix.cc --- a/liboctave/fMatrix.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/fMatrix.cc Tue Feb 23 16:12:27 2010 +0100 @@ -2049,7 +2049,8 @@ float& rcon, solve_singularity_handler sing_handler, blas_trans_type transt) const { FloatMatrix tmp (b); - return solve (typ, tmp, info, rcon, sing_handler, transt).column(static_cast (0)); + tmp = solve (typ, tmp, info, rcon, sing_handler, true, transt); + return tmp.column(static_cast (0)); } FloatComplexColumnVector diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/fMatrix.h --- a/liboctave/fMatrix.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/fMatrix.h Tue Feb 23 16:12:27 2010 +0100 @@ -24,7 +24,6 @@ #if !defined (octave_FloatMatrix_int_h) #define octave_FloatMatrix_int_h 1 -#include "Array2.h" #include "MArray.h" #include "MDiagArray2.h" #include "MatrixType.h" @@ -60,9 +59,6 @@ FloatMatrix (const MArray& a) : MArray (a.as_matrix ()) { } template - FloatMatrix (const Array2& a) : MArray (a) { } - - template FloatMatrix (const Array& a) : MArray (a.as_matrix ()) { } explicit FloatMatrix (const FloatRowVector& rv); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/fNDArray.cc --- a/liboctave/fNDArray.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/fNDArray.cc Tue Feb 23 16:12:27 2010 +0100 @@ -872,7 +872,7 @@ FloatMatrix retval; if (ndims () == 2) - retval = FloatMatrix (Array2 (*this)); + retval = FloatMatrix (Array (*this)); else (*current_liboctave_error_handler) ("invalid conversion of FloatNDArray to FloatMatrix"); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/lo-specfun.cc --- a/liboctave/lo-specfun.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/lo-specfun.cc Tue Feb 23 16:12:27 2010 +0100 @@ -999,7 +999,7 @@ static inline ComplexMatrix do_bessel (dptr f, const char *, double alpha, const ComplexMatrix& x, - bool scaled, Array2& ierr) + bool scaled, Array& ierr) { octave_idx_type nr = x.rows (); octave_idx_type nc = x.cols (); @@ -1017,7 +1017,7 @@ static inline ComplexMatrix do_bessel (dptr f, const char *, const Matrix& alpha, const Complex& x, - bool scaled, Array2& ierr) + bool scaled, Array& ierr) { octave_idx_type nr = alpha.rows (); octave_idx_type nc = alpha.cols (); @@ -1035,7 +1035,7 @@ static inline ComplexMatrix do_bessel (dptr f, const char *fn, const Matrix& alpha, - const ComplexMatrix& x, bool scaled, Array2& ierr) + const ComplexMatrix& x, bool scaled, Array& ierr) { ComplexMatrix retval; @@ -1123,7 +1123,7 @@ static inline ComplexMatrix do_bessel (dptr f, const char *, const RowVector& alpha, - const ComplexColumnVector& x, bool scaled, Array2& ierr) + const ComplexColumnVector& x, bool scaled, Array& ierr) { octave_idx_type nr = x.length (); octave_idx_type nc = alpha.length (); @@ -1149,7 +1149,7 @@ #define SM_BESSEL(name, fcn) \ ComplexMatrix \ name (double alpha, const ComplexMatrix& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1157,7 +1157,7 @@ #define MS_BESSEL(name, fcn) \ ComplexMatrix \ name (const Matrix& alpha, const Complex& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1165,7 +1165,7 @@ #define MM_BESSEL(name, fcn) \ ComplexMatrix \ name (const Matrix& alpha, const ComplexMatrix& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1197,7 +1197,7 @@ #define RC_BESSEL(name, fcn) \ ComplexMatrix \ name (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1596,7 +1596,7 @@ static inline FloatComplexMatrix do_bessel (fptr f, const char *, float alpha, const FloatComplexMatrix& x, - bool scaled, Array2& ierr) + bool scaled, Array& ierr) { octave_idx_type nr = x.rows (); octave_idx_type nc = x.cols (); @@ -1614,7 +1614,7 @@ static inline FloatComplexMatrix do_bessel (fptr f, const char *, const FloatMatrix& alpha, const FloatComplex& x, - bool scaled, Array2& ierr) + bool scaled, Array& ierr) { octave_idx_type nr = alpha.rows (); octave_idx_type nc = alpha.cols (); @@ -1632,7 +1632,7 @@ static inline FloatComplexMatrix do_bessel (fptr f, const char *fn, const FloatMatrix& alpha, - const FloatComplexMatrix& x, bool scaled, Array2& ierr) + const FloatComplexMatrix& x, bool scaled, Array& ierr) { FloatComplexMatrix retval; @@ -1720,7 +1720,7 @@ static inline FloatComplexMatrix do_bessel (fptr f, const char *, const FloatRowVector& alpha, - const FloatComplexColumnVector& x, bool scaled, Array2& ierr) + const FloatComplexColumnVector& x, bool scaled, Array& ierr) { octave_idx_type nr = x.length (); octave_idx_type nc = alpha.length (); @@ -1746,7 +1746,7 @@ #define SM_BESSEL(name, fcn) \ FloatComplexMatrix \ name (float alpha, const FloatComplexMatrix& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1754,7 +1754,7 @@ #define MS_BESSEL(name, fcn) \ FloatComplexMatrix \ name (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1762,7 +1762,7 @@ #define MM_BESSEL(name, fcn) \ FloatComplexMatrix \ name (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1794,7 +1794,7 @@ #define RC_BESSEL(name, fcn) \ FloatComplexMatrix \ name (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, \ - Array2& ierr) \ + Array& ierr) \ { \ return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ } @@ -1893,7 +1893,7 @@ } ComplexMatrix -airy (const ComplexMatrix& z, bool deriv, bool scaled, Array2& ierr) +airy (const ComplexMatrix& z, bool deriv, bool scaled, Array& ierr) { octave_idx_type nr = z.rows (); octave_idx_type nc = z.cols (); @@ -1910,7 +1910,7 @@ } ComplexMatrix -biry (const ComplexMatrix& z, bool deriv, bool scaled, Array2& ierr) +biry (const ComplexMatrix& z, bool deriv, bool scaled, Array& ierr) { octave_idx_type nr = z.rows (); octave_idx_type nc = z.cols (); @@ -2023,7 +2023,7 @@ } FloatComplexMatrix -airy (const FloatComplexMatrix& z, bool deriv, bool scaled, Array2& ierr) +airy (const FloatComplexMatrix& z, bool deriv, bool scaled, Array& ierr) { octave_idx_type nr = z.rows (); octave_idx_type nc = z.cols (); @@ -2040,7 +2040,7 @@ } FloatComplexMatrix -biry (const FloatComplexMatrix& z, bool deriv, bool scaled, Array2& ierr) +biry (const FloatComplexMatrix& z, bool deriv, bool scaled, Array& ierr) { octave_idx_type nr = z.rows (); octave_idx_type nc = z.cols (); diff -r 5150ceb4dbb4 -r a3635bc1ea19 liboctave/lo-specfun.h --- a/liboctave/lo-specfun.h Tue Feb 23 14:15:34 2010 +0100 +++ b/liboctave/lo-specfun.h Tue Feb 23 16:12:27 2010 +0100 @@ -27,7 +27,6 @@ #include "oct-cmplx.h" #include "Array.h" -template class Array2; class Matrix; class ComplexMatrix; class NDArray; @@ -130,75 +129,75 @@ extern OCTAVE_API ComplexMatrix besselj (double alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix bessely (double alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besseli (double alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselk (double alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh1 (double alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh2 (double alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselj (const Matrix& alpha, const Complex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix bessely (const Matrix& alpha, const Complex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besseli (const Matrix& alpha, const Complex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselk (const Matrix& alpha, const Complex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh1 (const Matrix& alpha, const Complex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh2 (const Matrix& alpha, const Complex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselj (const Matrix& alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix bessely (const Matrix& alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besseli (const Matrix& alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselk (const Matrix& alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh1 (const Matrix& alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh2 (const Matrix& alpha, const ComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexNDArray besselj (double alpha, const ComplexNDArray& x, bool scaled, @@ -274,27 +273,27 @@ extern OCTAVE_API ComplexMatrix besselj (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix bessely (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besseli (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselk (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh1 (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API ComplexMatrix besselh2 (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplex besselj (float alpha, const FloatComplex& x, bool scaled, octave_idx_type& ierr); @@ -316,75 +315,75 @@ extern OCTAVE_API FloatComplexMatrix besselj (float alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix bessely (float alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besseli (float alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselk (float alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh1 (float alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh2 (float alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselj (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix bessely (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besseli (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselk (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh1 (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh2 (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselj (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix bessely (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besseli (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselk (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh1 (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh2 (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexNDArray besselj (float alpha, const FloatComplexNDArray& x, bool scaled, @@ -460,36 +459,36 @@ extern OCTAVE_API FloatComplexMatrix besselj (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix bessely (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besseli (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselk (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh1 (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API FloatComplexMatrix besselh2 (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, - Array2& ierr); + Array& ierr); extern OCTAVE_API Complex airy (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr); extern OCTAVE_API Complex biry (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr); extern OCTAVE_API ComplexMatrix -airy (const ComplexMatrix& z, bool deriv, bool scaled, Array2& ierr); +airy (const ComplexMatrix& z, bool deriv, bool scaled, Array& ierr); extern OCTAVE_API ComplexMatrix -biry (const ComplexMatrix& z, bool deriv, bool scaled, Array2& ierr); +biry (const ComplexMatrix& z, bool deriv, bool scaled, Array& ierr); extern OCTAVE_API ComplexNDArray airy (const ComplexNDArray& z, bool deriv, bool scaled, Array& ierr); @@ -501,10 +500,10 @@ extern OCTAVE_API FloatComplex biry (const FloatComplex& z, bool deriv, bool scaled, octave_idx_type& ierr); extern OCTAVE_API FloatComplexMatrix -airy (const FloatComplexMatrix& z, bool deriv, bool scaled, Array2& ierr); +airy (const FloatComplexMatrix& z, bool deriv, bool scaled, Array& ierr); extern OCTAVE_API FloatComplexMatrix -biry (const FloatComplexMatrix& z, bool deriv, bool scaled, Array2& ierr); +biry (const FloatComplexMatrix& z, bool deriv, bool scaled, Array& ierr); extern OCTAVE_API FloatComplexNDArray airy (const FloatComplexNDArray& z, bool deriv, bool scaled, Array& ierr); diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/ChangeLog --- a/src/ChangeLog Tue Feb 23 14:15:34 2010 +0100 +++ b/src/ChangeLog Tue Feb 23 16:12:27 2010 +0100 @@ -1,3 +1,13 @@ +2010-02-24 Jaroslav Hajek + + * TEMPLATE-INST/Array-tc.cc: Remove Array2 instantiation. + * DLD-FUNCTIONS/besselj.cc: Use Array instead of Array2. + * DLD-FUNCTIONS/tril.cc: Ditto. + * data.cc: Ditto. + * ov-typeinfo.cc: Ditto. + * ov-typeinfo.h: Ditto. + * pr-output.cc: Ditto. + 2010-02-23 Jaroslav Hajek * ov-bool-mat.h (octave_bool_matrix::octave_bool_matrix (const diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/DLD-FUNCTIONS/besselj.cc --- a/src/DLD-FUNCTIONS/besselj.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/src/DLD-FUNCTIONS/besselj.cc Tue Feb 23 16:12:27 2010 +0100 @@ -169,7 +169,7 @@ if (! error_state) { - Array2 ierr; + Array ierr; octave_value result; DO_BESSEL (type, ralpha, cx, scaled, ierr, result); @@ -304,7 +304,7 @@ if (! error_state) { - Array2 ierr; + Array ierr; octave_value result; DO_BESSEL (type, ralpha, cx, scaled, ierr, result); diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/DLD-FUNCTIONS/tril.cc --- a/src/DLD-FUNCTIONS/tril.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/src/DLD-FUNCTIONS/tril.cc Tue Feb 23 16:12:27 2010 +0100 @@ -49,7 +49,7 @@ octave_idx_type j1 = std::min (std::max (zero, k), nc); octave_idx_type j2 = std::min (std::max (zero, nr + k), nc); octave_idx_type n = j1 * nr + ((j2 - j1) * (nr-(j1-k) + nr-(j2-1-k))) / 2; - Array r (n); + Array r (n, 1); T *rvec = r.fortran_vec (); for (octave_idx_type j = 0; j < nc; j++) { @@ -90,7 +90,7 @@ octave_idx_type j1 = std::min (std::max (zero, k), nc); octave_idx_type j2 = std::min (std::max (zero, nr + k), nc); octave_idx_type n = ((j2 - j1) * ((j1+1-k) + (j2-k))) / 2 + (nc - j2) * nr; - Array r (n); + Array r (n, 1); T *rvec = r.fortran_vec (); for (octave_idx_type j = 0; j < nc; j++) { diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/TEMPLATE-INST/Array-tc.cc --- a/src/TEMPLATE-INST/Array-tc.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/src/TEMPLATE-INST/Array-tc.cc Tue Feb 23 16:12:27 2010 +0100 @@ -30,8 +30,6 @@ #include "Array.h" #include "Array.cc" -#include "Array2.h" - #include "ov.h" #include "oct-sort.cc" @@ -39,5 +37,3 @@ NO_INSTANTIATE_ARRAY_SORT (octave_value); INSTANTIATE_ARRAY (octave_value, OCTINTERP_API); - -template class OCTINTERP_API Array2; diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/data.cc --- a/src/data.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/src/data.cc Tue Feb 23 16:12:27 2010 +0100 @@ -4891,46 +4891,21 @@ return retval; } - // Remove trailing singletons in new_size, but leave at least 2 - // elements. - - int n = new_size.length (); - - while (n > 2) + dim_vector new_dims = dim_vector::alloc (new_size.length ()); + + for (octave_idx_type i = 0; i < new_size.length (); i++) { - if (new_size(n-1) == 1) - n--; + if (new_size(i) < 0) + { + error ("reshape: size must be nonnegative"); + break; + } else - break; - } - - if (n < 2) - { - error ("reshape: expecting size to be vector with at least 2 elements"); - return retval; + new_dims(i) = new_size(i); } - dim_vector new_dims; - - new_dims.resize (n); - - for (octave_idx_type i = 0; i < n; i++) - new_dims(i) = new_size(i); - - octave_value arg = args(0); - - dim_vector dims = arg.dims (); - - if (new_dims.numel () == dims.numel ()) - retval = (new_dims == dims) ? arg : arg.reshape (new_dims); - else - { - std::string dims_str = dims.str (); - std::string new_dims_str = new_dims.str (); - - error ("reshape: can't reshape %s array to %s array", - dims_str.c_str (), new_dims_str.c_str ()); - } + if (! error_state) + retval = args(0).reshape (new_dims); return retval; } diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/ov-typeinfo.cc --- a/src/ov-typeinfo.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/src/ov-typeinfo.cc Tue Feb 23 16:12:27 2010 +0100 @@ -37,7 +37,6 @@ octave_value_typeinfo::instance (0); #include -#include #include bool diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/ov-typeinfo.h --- a/src/ov-typeinfo.h Tue Feb 23 14:15:34 2010 +0100 +++ b/src/ov-typeinfo.h Tue Feb 23 16:12:27 2010 +0100 @@ -27,7 +27,6 @@ #include #include "Array.h" -#include "Array2.h" #include "Array3.h" #include "ov.h" @@ -222,9 +221,9 @@ Array unary_class_ops; - Array2 unary_ops; + Array unary_ops; - Array2 non_const_unary_ops; + Array non_const_unary_ops; Array binary_class_ops; @@ -234,17 +233,17 @@ Array3 compound_binary_ops; - Array2 cat_ops; + Array cat_ops; Array3 assign_ops; - Array2 assignany_ops; + Array assignany_ops; - Array2 pref_assign_conv; + Array pref_assign_conv; - Array2 type_conv_ops; + Array type_conv_ops; - Array2 widening_ops; + Array widening_ops; int do_register_type (const std::string&, const std::string&, const octave_value&); diff -r 5150ceb4dbb4 -r a3635bc1ea19 src/pr-output.cc --- a/src/pr-output.cc Tue Feb 23 14:15:34 2010 +0100 +++ b/src/pr-output.cc Tue Feb 23 16:12:27 2010 +0100 @@ -1893,7 +1893,7 @@ idx(k) = idx_vector (ra_idx(k)); \ \ octave_value page \ - = MAT_T (Array2 (nda.index (idx), nr, nc)); \ + = MAT_T (Array (nda.index (idx), nr, nc)); \ \ page.print_with_name (os, nm); \ \ @@ -2726,7 +2726,7 @@ for (int k = 2; k < ndims; k++) idx(k) = idx_vector (ra_idx(k)); - Array2 page (nda.index (idx), nr, nc); + Array page (nda.index (idx), nr, nc); // FIXME -- need to do some more work to put these // in neatly aligned columns... @@ -2993,7 +2993,7 @@ for (int k = 2; k < ndims; k++) idx(k) = idx_vector (ra_idx(k)); - Array2 page (nda.index (idx), nr, nc); + Array page (nda.index (idx), nr, nc); for (octave_idx_type ii = 0; ii < nr; ii++) { @@ -3098,7 +3098,7 @@ for (int k = 2; k < ndims; k++) idx(k) = idx_vector (ra_idx(k)); - Array2 page (nda.index (idx), nr, nc); + Array page (nda.index (idx), nr, nc); if (free_format) {