# HG changeset patch # User jwe # Date 1059519932 0 # Node ID 32ac2bea0185217fc98e2d2bd943dcf292fde326 # Parent f52db9e1296abfea93935dd927aa97dd8a412be7 [project @ 2003-07-29 23:05:32 by jwe] diff --git a/libcruft/ChangeLog b/libcruft/ChangeLog --- a/libcruft/ChangeLog +++ b/libcruft/ChangeLog @@ -1,7 +1,7 @@ 2003-07-29 John W. Eaton * Makefile.in (install-lib): Use $(INSTALL), not - $(INSTALL_PROGRAM) for $(SHLBIN) files. + $(INSTALL_PROGRAM) for $(SHLLIB) files. 2003-07-02 John W. Eaton diff --git a/libcruft/Makefile.in b/libcruft/Makefile.in --- a/libcruft/Makefile.in +++ b/libcruft/Makefile.in @@ -132,13 +132,13 @@ fi if $(SHARED_LIBS); then \ rm -f $(DESTDIR)$(octlibdir)/libcruft.$(SHLLIB_VER); \ - $(INSTALL_PROGRAM) \ + $(INSTALL) \ libcruft.$(SHLLIB) $(DESTDIR)$(octlibdir)/libcruft.$(SHLLIB_VER); \ rm -f $(DESTDIR)$(octlibdir)/libcruft.$(SHLLIB); \ $(LN_S) libcruft.$(SHLLIB_VER) $(DESTDIR)$(octlibdir)/libcruft.$(SHLLIB); \ if test x$(SHLBIN) != x ; then \ rm -f $(DESTDIR)$(bindir)/libcruft.$(SHLBIN); \ - $(INSTALL) \ + $(INSTALL_PROGRAM) \ libcruft.$(SHLBIN) $(DESTDIR)$(bindir)/libcruft.$(SHLBIN); \ fi; \ fi diff --git a/liboctave/ArrayN.cc b/liboctave/ArrayN.cc --- a/liboctave/ArrayN.cc +++ b/liboctave/ArrayN.cc @@ -229,6 +229,8 @@ if (no_change) return; + int old_len = length (); + typename Array::ArrayRep *old_rep = Array::rep; const T *old_data = data (); @@ -236,8 +238,6 @@ Array old_dimensions = dimensions; - int old_len = length (); - dimensions = dims; Array ra_idx (dimensions.length (), 0); @@ -287,14 +287,14 @@ typename Array::ArrayRep *old_rep = Array::rep; const T *old_data = data (); + int old_len = length (); + int len = get_size (dims); Array::rep = new typename Array::ArrayRep (len); Array old_dimensions = dimensions; - int old_len = length (); - dimensions = dims; Array ra_idx (dimensions.length (), 0); @@ -354,22 +354,110 @@ std::ostream& operator << (std::ostream& os, const ArrayN& a) { - Array dims = a.dimensions; + Array a_dims = a.dimensions; + + int n_dims = a_dims.length (); + + os << n_dims << "-dimensional array"; + + if (n_dims) + { + os << " ("; + + for (int i = 0; i < n_dims - 1; i++) + os << a_dims(i) << "x"; + + os << a_dims(n_dims-1) << ")"; + } + + os <<"\n\n"; - int n_dims = dims.length (); + if (n_dims) + { + os << "data:"; + + Array ra_idx (n_dims,0); + + // Number of times the first 2d-array is to be displayed. - os << n_dims << "-dimensional array ("; + int m = 1; + for (int i = 2; i < n_dims; i++) + m *= a_dims(i); + + if (m == 1) + { + int rows = 0; + int cols = 0; + + switch (n_dims) + { + case 2: + rows = a_dims(0); + cols = a_dims(1); - for (int i = 0; i < n_dims - 1; i++) - os << dims(i) << "x"; - os << dims(n_dims-1) << ")\n\n"; + for (int j = 0; j < rows; j++) + { + ra_idx(0) = j; + for (int k = 0; k < cols; k++) + { + ra_idx(1) = k; + os << " " << a.elem(ra_idx); + } + os << "\n"; + } + break; + + case 1: + rows = a_dims(0); + + for (int k = 0; k < rows; k++) + { + ra_idx(0) = k; + os << " " << a.elem(ra_idx); + } + break; + + default: + (*current_liboctave_error_handler) + ("std::operator <<: problems with dimensions (= 0)!"); + } - os << "data:\n"; + os << "\n"; + } + else + { + int rows = a_dims(0); + int cols = a_dims(1); + + for (int i = 0; i < m; i++) + { + os << "\n(:,:,"; + + for (int j = 2; j < n_dims - 1; j++) + os << ra_idx(j) + 1 << ","; + + os << ra_idx(n_dims - 1) + 1 << ") = \n"; - int n = ArrayN::get_size (dims); + for (int j = 0; j < rows; j++) + { + ra_idx(0) = j; + + for (int k = 0; k < cols; k++) + { + ra_idx(1) = k; + os << " " << a.elem(ra_idx); + } - // for (int i = 0; i < n; i++) - // os << a.elem (i) << "\n"; + os << "\n"; + } + + os << "\n"; + + if (i != m - 1) + increment_index (ra_idx, a_dims, 2); + } + } + } return os; } diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,7 +1,18 @@ +2003-07-29 Heine Kolltveit + + * ArrayN.cc (operator <<): Improve output readability. + (increment_index (Array&, Array&, int)) New function. + +2003-07-29 Petter Risholm + + * ArrayN.cc (ArrayN::resize (const Array&, const T&)): + * ArrayN.cc (ArrayN::resize (const Array&)): + Initialize old_len before changing size. + 2003-07-29 John W. Eaton * Makefile.in (install-lib): Use $(INSTALL), not - $(INSTALL_PROGRAM) for $(SHLBIN) files. + $(INSTALL_PROGRAM) for $(SHLLIB) files. 2003-07-25 John W. Eaton diff --git a/liboctave/Makefile.in b/liboctave/Makefile.in --- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -247,13 +247,13 @@ fi if $(SHARED_LIBS); then \ rm -f $(DESTDIR)$(octlibdir)/liboctave.$(SHLLIB_VER); \ - $(INSTALL_PROGRAM) \ + $(INSTALL \ liboctave.$(SHLLIB) $(DESTDIR)$(octlibdir)/liboctave.$(SHLLIB_VER); \ rm -f $(DESTDIR)$(octlibdir)/liboctave.$(SHLLIB); \ $(LN_S) liboctave.$(SHLLIB_VER) $(DESTDIR)$(octlibdir)/liboctave.$(SHLLIB); \ if test x$(SHLBIN) != x ; then \ rm -f $(DESTDIR)$(bindir)/liboctave.$(SHLBIN); \ - $(INSTALL) \ + $(INSTALL_PROGRAM) \ liboctave.$(SHLBIN) $(DESTDIR)$(bindir)/liboctave.$(SHLBIN); \ fi; \ fi diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,7 @@ 2003-07-29 John W. Eaton * Makefile.in (install-lib): Use $(INSTALL), not - $(INSTALL_PROGRAM) for $(SHLBIN) files. + $(INSTALL_PROGRAM) for $(SHLLIB) files. 2003-07-29 Paul Kienzle diff --git a/src/Makefile.in b/src/Makefile.in --- a/src/Makefile.in +++ b/src/Makefile.in @@ -366,13 +366,13 @@ fi if $(SHARED_LIBS); then \ rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLEXT_VER); \ - $(INSTALL_PROGRAM) liboctinterp.$(SHLLIB) \ + $(INSTALL) liboctinterp.$(SHLLIB) \ $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB_VER); \ rm -f $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB); \ $(LN_S) liboctinterp.$(SHLLIB_VER) $(DESTDIR)$(octlibdir)/liboctinterp.$(SHLLIB); \ if test x$(SHLBIN) != x ; then \ rm -f $(DESTDIR)$(bindir)/liboctinterp.$(SHLBIN); \ - $(INSTALL) \ + $(INSTALL_PROGRAM) \ liboctinterp.$(SHLBIN) $(DESTDIR)$(bindir)/liboctinterp.$(SHLBIN); \ fi; \ fi