Mercurial > hg > octave-shane
changeset 4473:32ac2bea0185
[project @ 2003-07-29 23:05:32 by jwe]
author | jwe |
---|---|
date | Tue, 29 Jul 2003 23:05:32 +0000 |
parents | f52db9e1296a |
children | f62a7ed4fb06 |
files | libcruft/ChangeLog libcruft/Makefile.in liboctave/ArrayN.cc liboctave/ChangeLog liboctave/Makefile.in src/ChangeLog src/Makefile.in |
diffstat | 7 files changed, 122 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libcruft/ChangeLog +++ b/libcruft/ChangeLog @@ -1,7 +1,7 @@ 2003-07-29 John W. Eaton <jwe@bevo.che.wisc.edu> * Makefile.in (install-lib): Use $(INSTALL), not - $(INSTALL_PROGRAM) for $(SHLBIN) files. + $(INSTALL_PROGRAM) for $(SHLLIB) files. 2003-07-02 John W. Eaton <jwe@bevo.che.wisc.edu>
--- 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
--- a/liboctave/ArrayN.cc +++ b/liboctave/ArrayN.cc @@ -229,6 +229,8 @@ if (no_change) return; + int old_len = length (); + typename Array<T>::ArrayRep *old_rep = Array<T>::rep; const T *old_data = data (); @@ -236,8 +238,6 @@ Array<int> old_dimensions = dimensions; - int old_len = length (); - dimensions = dims; Array<int> ra_idx (dimensions.length (), 0); @@ -287,14 +287,14 @@ typename Array<T>::ArrayRep *old_rep = Array<T>::rep; const T *old_data = data (); + int old_len = length (); + int len = get_size (dims); Array<T>::rep = new typename Array<T>::ArrayRep (len); Array<int> old_dimensions = dimensions; - int old_len = length (); - dimensions = dims; Array<int> ra_idx (dimensions.length (), 0); @@ -354,22 +354,110 @@ std::ostream& operator << (std::ostream& os, const ArrayN<T>& a) { - Array<int> dims = a.dimensions; + Array<int> 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<int> 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<T>::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; }
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,7 +1,18 @@ +2003-07-29 Heine Kolltveit <kolltvei@idi.ntnu.no> + + * ArrayN.cc (operator <<): Improve output readability. + (increment_index (Array<int>&, Array<int>&, int)) New function. + +2003-07-29 Petter Risholm <risholm@stud.ntnu.no> + + * ArrayN.cc (ArrayN<T>::resize (const Array<int>&, const T&)): + * ArrayN.cc (ArrayN<T>::resize (const Array<int>&)): + Initialize old_len before changing size. + 2003-07-29 John W. Eaton <jwe@bevo.che.wisc.edu> * Makefile.in (install-lib): Use $(INSTALL), not - $(INSTALL_PROGRAM) for $(SHLBIN) files. + $(INSTALL_PROGRAM) for $(SHLLIB) files. 2003-07-25 John W. Eaton <jwe@bevo.che.wisc.edu>
--- 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
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,7 @@ 2003-07-29 John W. Eaton <jwe@bevo.che.wisc.edu> * Makefile.in (install-lib): Use $(INSTALL), not - $(INSTALL_PROGRAM) for $(SHLBIN) files. + $(INSTALL_PROGRAM) for $(SHLLIB) files. 2003-07-29 Paul Kienzle <pkienzle@users.sf.net>
--- 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