Mercurial > hg > octave-lyh
changeset 2306:2fbf9bb1cd7a
[project @ 1996-07-09 16:49:03 by jwe]
author | jwe |
---|---|
date | Tue, 09 Jul 1996 16:51:04 +0000 |
parents | 5a3f1d00a474 |
children | 8b0da674a62d |
files | liboctave/Array.h liboctave/Array2.h liboctave/Array3.cc liboctave/Array3.h |
diffstat | 4 files changed, 64 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -182,18 +182,18 @@ } } -#if defined (BOUNDS_CHECKING) - T& elem (int n) { return checkelem (n); } -#else T& elem (int n) { make_unique (); return xelem (n); } + +#if defined (BOUNDS_CHECKING) + T& operator () (int n) { return checkelem (n); } +#else + T& operator () (int n) { return elem (n); } #endif - T& operator () (int n) { return elem (n); } - T Array<T>::checkelem (int n) const { if (n < 0 || n >= rep->length ()) @@ -202,14 +202,14 @@ return xelem (n); } + T Array<T>::elem (int n) const { return xelem (n); } + #if defined (BOUNDS_CHECKING) - T Array<T>::elem (int n) const { return checkelem (n); } + T Array<T>::operator () (int n) const { return checkelem (n); } #else - T Array<T>::elem (int n) const { return xelem (n); } + T Array<T>::operator () (int n) const { return elem (n); } #endif - T Array<T>::operator () (int n) const { return elem (n); } - void resize (int n); void resize (int n, const T& val);
--- a/liboctave/Array2.h +++ b/liboctave/Array2.h @@ -120,9 +120,9 @@ T& xelem (int i, int j) { return Array<T>::xelem (d1*j+i); } T xelem (int i, int j) const { return Array<T>::xelem (d1*j+i); } - // Note that the following element references don't use - // Array2<T>::xelem() because they still need to make use of the - // code in Array<T> that checks the reference count. + // Note that the following element selection methods don't use + // xelem() because they need to make use of the code in + // Array<T>::elem() that checks the reference count. T& checkelem (int i, int j) { @@ -137,14 +137,14 @@ return Array<T>::elem (d1*j+i); } + T& elem (int i, int j) { return Array<T>::elem (d1*j+i); } + #if defined (BOUNDS_CHECKING) - T& elem (int i, int j) { return checkelem (i, j); } + T& operator () (int i, int j) { return checkelem (i, j); } #else - T& elem (int i, int j) { return Array<T>::elem (d1*j+i); } + T& operator () (int i, int j) { return elem (i, j); } #endif - T& operator () (int i, int j) { return elem (i, j); } - T checkelem (int i, int j) const { if (i < 0 || j < 0 || i >= d1 || j >= d2) @@ -159,14 +159,14 @@ return Array<T>::elem (d1*j+i); } + T elem (int i, int j) const { return Array<T>::elem (d1*j+i); } + #if defined (BOUNDS_CHECKING) - T elem (int i, int j) const { return checkelem (i, j); } + T operator () (int i, int j) const { return checkelem (i, j); } #else - T elem (int i, int j) const { return Array<T>::elem (d1*j+i); } + T operator () (int i, int j) const { return elem (i, j); } #endif - T operator () (int i, int j) const { return elem (i, j); } - T range_error (const char *fcn, int i, int j) const; T& range_error (const char *fcn, int i, int j);
--- a/liboctave/Array3.cc +++ b/liboctave/Array3.cc @@ -45,54 +45,6 @@ // Three dimensional array class. template <class T> -T& -Array3<T>::checkelem (int i, int j, int k) -{ - if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) - { - (*current_liboctave_error_handler) ("range error"); - static T foo; - return foo; - } - return Array2<T>::elem (i, d2*k+j); -} - -template <class T> -T -Array3<T>::elem (int i, int j, int k) const -{ - return Array2<T>::elem (i, d2*k+j); -} - -template <class T> -T -Array3<T>::checkelem (int i, int j, int k) const -{ - if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) - { - (*current_liboctave_error_handler) ("range error"); - T foo; - static T *bar = &foo; - return foo; - } - return Array2<T>::elem (i, d1*k+j); -} - -template <class T> -T -Array3<T>::operator () (int i, int j, int k) const -{ - if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) - { - (*current_liboctave_error_handler) ("range error"); - T foo; - static T *bar = &foo; - return foo; - } - return Array2<T>::elem (i, d2*k+j); -} - -template <class T> void Array3<T>::resize (int n, int m, int k) {
--- a/liboctave/Array3.h +++ b/liboctave/Array3.h @@ -99,17 +99,53 @@ int dim3 (void) const { return d3; } - T& elem (int i, int j, int k) { return Array2<T>::elem (i, d2*k+j); } - T& checkelem (int i, int j, int k); - T& operator () (int i, int j, int k) { return checkelem (i, j, k); } - - // No checking. + // No checking of any kind, ever. T& xelem (int i, int j, int k) { return Array2<T>::xelem (i, d2*k+j); } + T xelem (int i, int j, int k) const { return Array2<T>::xelem (i, d2*k+j); } - T elem (int i, int j, int k) const; - T checkelem (int i, int j, int k) const; - T operator () (int i, int j, int k) const; + // Note that the following element selection methods don't use + // xelem() because they need to make use of the code in + // Array<T>::elem() that checks the reference count. + + T& checkelem (int i, int j, int k) + { + if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) + { + (*current_liboctave_error_handler) ("range error"); + static T foo; + return foo; + } + return Array2<T>::elem (i, d2*k+j); + } + + T& elem (int i, int j, int k) { return Array2<T>::elem (i, d2*k+j); } + +#if defined (BOUNDS_CHECKING) + T& operator () (int i, int j, int k) { return checkelem (i, j, k); } +#else + T& operator () (int i, int j, int k) { return elem (i, j, k); } +#endif + + T checkelem (int i, int j, int k) const + { + if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) + { + (*current_liboctave_error_handler) ("range error"); + T foo; + static T *bar = &foo; + return foo; + } + return Array2<T>::elem (i, d1*k+j); + } + + T elem (int i, int j, int k) const { return Array2<T>::elem (i, d2*k+j); } + +#if defined (BOUNDS_CHECKING) + T operator () (int i, int j, int k) const { return checkelem (i, j, k); } +#else + T operator () (int i, int j, int k) const { return elem (i, j, k); } +#endif void resize (int n, int m, int k); void resize (int n, int m, int k, const T& val);