Mercurial > hg > octave-nkf
changeset 344:a7fd0923e4e4
[project @ 1994-02-08 05:52:11 by jwe]
author | jwe |
---|---|
date | Tue, 08 Feb 1994 05:56:08 +0000 |
parents | ecb6f1e11842 |
children | 4f9072d00bec |
files | liboctave/Array.cc liboctave/Array.h src/pt-const.cc |
diffstat | 3 files changed, 52 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -831,6 +831,41 @@ return nc; } +#if defind (_AIX) +template <class T> +T& +DiagArray<T>::elem (int r, int c) +{ + static T foo (0); + return (r == c) ? Array<T>::elem (r) : foo; +} + +template <class T> +T& +DiagArray<T>::checkelem (int r, int c) +{ + static T foo (0); + if (r < 0 || c < 0 || r >= nr || c >= nc) + { + (*current_liboctave_error_handler) ("range error"); + return foo; + } + return (r == c) ? Array<T>::elem (r) : foo; +} + +template <class T> +T& +DiagArray<T>::operator () (int r, int c) +{ + static T foo (0); + if (r < 0 || c < 0 || r >= nr || c >= nc) + { + (*current_liboctave_error_handler) ("range error"); + return foo; + } + return (r == c) ? Array<T>::elem (r) : foo; +} + template <class T> T& DiagArray<T>::xelem (int r, int c)
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -227,6 +227,7 @@ template <class T> class DiagArray : public Array<T> { +#if ! defined (_AIX) private: class Proxy @@ -276,6 +277,7 @@ }; friend class Proxy; +#endif protected: @@ -303,6 +305,11 @@ int cols (void) const; int columns (void) const; +#if defined (_AIX) + T& elem (int r, int c); + T& checkelem (int r, int c); + T& operator () (int r, int c); +#else Proxy elem (int r, int c) { return Proxy (this, r, c); @@ -329,6 +336,7 @@ else return Proxy (this, r, c); } +#endif // No checking. T& xelem (int r, int c);
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -611,7 +611,15 @@ i++; - assert (i > 0 && (nr <= 1 || nc <= 1)); + assert (i >= 0 && (nr <= 1 || nc <= 1)); + +// This function never reduces the size of a vector, and all vectors +// have dimensions of at least 0x0. If i is 0, it is either because +// a vector has been indexed with a vector of all zeros (in which case +// the index vector is empty and nothing will happen) or a vector has +// been indexed with 0 (an error which will be caught elsewhere). + if (i == 0) + return; if (nr <= 1 && nc <= 1 && i >= 1) {