Mercurial > hg > octave-nkf
changeset 4273:d9f281027014
[project @ 2003-01-03 19:58:12 by jwe]
author | jwe |
---|---|
date | Fri, 03 Jan 2003 20:00:42 +0000 |
parents | fd406afe8a10 |
children | f7660e7d9b80 |
files | liboctave/ArrayN-idx.h liboctave/ArrayN.cc liboctave/ArrayN.h |
diffstat | 3 files changed, 84 insertions(+), 84 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ArrayN-idx.h +++ b/liboctave/ArrayN-idx.h @@ -42,22 +42,22 @@ if (n_idx > 1) { - Array<idx_vector> idx (n_idx); + Array<idx_vector> ra_idx (n_idx); idx_vector *tmp = get_idx (); for (int i = 0; i < n_idx; i++) - idx(i) = tmp[i]; + ra_idx(i) = tmp[i]; - return index (idx); + return index (ra_idx); } else if (n_idx == 1) { idx_vector *tmp = get_idx (); - idx_vector idx = tmp[0]; + idx_vector ra_idx = tmp[0]; - return index (idx); + return index (ra_idx); } else (*current_liboctave_error_handler) @@ -70,7 +70,7 @@ template <class T> ArrayN<T> -ArrayN<T>::index (idx_vector& idx, int resize_ok, +ArrayN<T>::index (idx_vector& ra_idx, int resize_ok, const T& resize_fill_value) const { ArrayN<T> retval; @@ -79,32 +79,32 @@ } static inline Array<int> -freeze (Array<idx_vector>& idx, const Array<int>& dimensions, int resize_ok) +freeze (Array<idx_vector>& ra_idx, const Array<int>& dimensions, int resize_ok) { Array<int> retval; - int n = idx.length (); + int n = ra_idx.length (); assert (n == dimensions.length ()); retval.resize (n); for (int i = 0; i < n; i++) - retval(i) = idx(i).freeze (dimensions(i), "XXX FIXME XXX", resize_ok); + retval(i) = ra_idx(i).freeze (dimensions(i), "XXX FIXME XXX", resize_ok); return retval; } static inline bool -all_ok (const Array<idx_vector>& idx) +all_ok (const Array<idx_vector>& ra_idx) { bool retval = true; - int n = idx.length (); + int n = ra_idx.length (); for (int i = 0; i < n; i++) { - if (! idx(i)) + if (! ra_idx(i)) { retval = false; break; @@ -115,15 +115,15 @@ } static inline bool -any_orig_empty (const Array<idx_vector>& idx) +any_orig_empty (const Array<idx_vector>& ra_idx) { bool retval = false; - int n = idx.length (); + int n = ra_idx.length (); for (int i = 0; i < n; i++) { - if (idx(i).orig_empty ()) + if (ra_idx(i).orig_empty ()) { retval = true; break; @@ -162,12 +162,12 @@ } static inline bool -all_colon_equiv (const Array<idx_vector>& idx, +all_colon_equiv (const Array<idx_vector>& ra_idx, const Array<int>& frozen_lengths) { bool retval = true; - int idx_n = idx.length (); + int idx_n = ra_idx.length (); int n = frozen_lengths.length (); @@ -175,7 +175,7 @@ for (int i = 0; i < n; i++) { - if (! idx(i).is_colon_equiv (frozen_lengths(i))) + if (! ra_idx(i).is_colon_equiv (frozen_lengths(i))) { retval = false; break; @@ -186,34 +186,34 @@ } static Array<int> -get_elt_idx (const Array<idx_vector>& idx, const Array<int>& result_idx) +get_elt_idx (const Array<idx_vector>& ra_idx, const Array<int>& result_idx) { - int n = idx.length (); + int n = ra_idx.length (); Array<int> retval (n); for (int i = 0; i < n; i++) - retval(i) = idx(result_idx(i)); + retval(i) = ra_idx(result_idx(i)); return retval; } template <class T> ArrayN<T> -ArrayN<T>::index (Array<idx_vector>& arr_idx, int resize_ok, +ArrayN<T>::index (Array<idx_vector>& ra_idx, int resize_ok, const T& resize_fill_value) const { ArrayN<T> retval; int n_dims = dimensions.length (); - Array<int> frozen_lengths = freeze (arr_idx, dimensions, resize_ok); + Array<int> frozen_lengths = freeze (ra_idx, dimensions, resize_ok); if (frozen_lengths.length () == n_dims) { - if (all_ok (arr_idx)) + if (all_ok (ra_idx)) { - if (any_orig_empty (arr_idx)) + if (any_orig_empty (ra_idx)) { retval.resize (frozen_lengths); } @@ -224,7 +224,7 @@ retval.resize (new_size); } - else if (all_colon_equiv (arr_idx, frozen_lengths)) + else if (all_colon_equiv (ra_idx, frozen_lengths)) { retval = *this; }
--- a/liboctave/ArrayN.cc +++ b/liboctave/ArrayN.cc @@ -46,25 +46,25 @@ template <class T> int -ArrayN<T>::compute_index (const Array<int>& arr_idx) const +ArrayN<T>::compute_index (const Array<int>& ra_idx) const { int retval = -1; int n = dimensions.length (); - if (n > 0 && n == arr_idx.length ()) + if (n > 0 && n == ra_idx.length ()) { - retval = arr_idx(--n); + retval = ra_idx(--n); while (--n >= 0) { retval *= dimensions(n); - retval += arr_idx(n); + retval += ra_idx(n); } } else (*current_liboctave_error_handler) - ("ArrayN<T>::compute_index: invalid arr_idxing operation"); + ("ArrayN<T>::compute_index: invalid ra_idxing operation"); return retval; } @@ -74,7 +74,7 @@ template <class T> int -ArrayN<T>::get_size (const Array<int>& arr_idx) +ArrayN<T>::get_size (const Array<int>& ra_idx) { // XXX KLUGE XXX @@ -97,18 +97,18 @@ int retval = max_items; - int n = arr_idx.length (); + int n = ra_idx.length (); int nt = 0; double dt = 1; for (int i = 0; i < n; i++) { - int narr_idx; - double darr_idx = frexp (static_cast<double> (arr_idx(i)), &narr_idx); + int nra_idx; + double dra_idx = frexp (static_cast<double> (ra_idx(i)), &nra_idx); - nt += narr_idx; - dt *= darr_idx; + nt += nra_idx; + dt *= dra_idx; } if (dt <= 0.5) @@ -125,7 +125,7 @@ retval = 1; for (int i = 0; i < n; i++) - retval *= arr_idx(i); + retval *= ra_idx(i); } return retval; @@ -135,7 +135,7 @@ template <class T> T -ArrayN<T>::range_error (const char *fcn, const Array<int>& arr_idx) const +ArrayN<T>::range_error (const char *fcn, const Array<int>& ra_idx) const { // XXX FIXME XXX -- report index values too! @@ -146,7 +146,7 @@ template <class T> T& -ArrayN<T>::range_error (const char *fcn, const Array<int>& arr_idx) +ArrayN<T>::range_error (const char *fcn, const Array<int>& ra_idx) { // XXX FIXME XXX -- report index values too! @@ -157,17 +157,17 @@ } static inline bool -index_in_bounds (const Array<int>& arr_idx, const Array<int>& dimensions) +index_in_bounds (const Array<int>& ra_idx, const Array<int>& dimensions) { bool retval = true; - int n = arr_idx.length (); + int n = ra_idx.length (); if (n == dimensions.length ()) { for (int i = 0; i < n; i++) { - if (arr_idx(i) < 0 || arr_idx(i) >= dimensions (i)) + if (ra_idx(i) < 0 || ra_idx(i) >= dimensions (i)) { retval = false; break; @@ -181,20 +181,20 @@ } static inline void -increment_index (Array<int>& arr_idx, const Array<int>& dimensions) +increment_index (Array<int>& ra_idx, const Array<int>& dimensions) { - arr_idx(0)++; + ra_idx(0)++; - int n = arr_idx.length () - 1; + int n = ra_idx.length () - 1; for (int i = 0; i < n; i++) { - if (arr_idx(i) < dimensions(i)) + if (ra_idx(i) < dimensions(i)) break; else { - arr_idx(i) = 0; - arr_idx(i+1)++; + ra_idx(i) = 0; + ra_idx(i+1)++; } } } @@ -240,14 +240,14 @@ dimensions = dims; - Array<int> arr_idx (dimensions.length (), 0); + Array<int> ra_idx (dimensions.length (), 0); for (int i = 0; i < old_len; i++) { - if (index_in_bounds (arr_idx, dimensions)) - xelem (arr_idx) = old_data[i]; + if (index_in_bounds (ra_idx, dimensions)) + xelem (ra_idx) = old_data[i]; - increment_index (arr_idx, dimensions); + increment_index (ra_idx, dimensions); } if (--old_rep->count <= 0) @@ -297,17 +297,17 @@ dimensions = dims; - Array<int> arr_idx (dimensions.length (), 0); + Array<int> ra_idx (dimensions.length (), 0); for (int i = 0; i < len; i++) rep->elem (i) = val; for (int i = 0; i < old_len; i++) { - if (index_in_bounds (arr_idx, dimensions)) - xelem (arr_idx) = old_data[i]; + if (index_in_bounds (ra_idx, dimensions)) + xelem (ra_idx) = old_data[i]; - increment_index (arr_idx, dimensions); + increment_index (ra_idx, dimensions); } if (--old_rep->count <= 0) @@ -316,9 +316,9 @@ template <class T> ArrayN<T>& -ArrayN<T>::insert (const ArrayN<T>& a, const Array<int>& arr_idx) +ArrayN<T>::insert (const ArrayN<T>& a, const Array<int>& ra_idx) { - int n = arr_idx.length (); + int n = ra_idx.length (); if (n == dimensions.length ()) { @@ -326,7 +326,7 @@ for (int i = 0; i < n; i++) { - if (arr_idx(i) < 0 || arr_idx(i) + a_dims(i) > dimensions(i)) + if (ra_idx(i) < 0 || ra_idx(i) + a_dims(i) > dimensions(i)) { (*current_liboctave_error_handler) ("ArrayN<T>::insert: range error for insert");
--- a/liboctave/ArrayN.h +++ b/liboctave/ArrayN.h @@ -104,69 +104,69 @@ return *this; } - int compute_index (const Array<int>& idx) const; + int compute_index (const Array<int>& ra_idx) const; Array<int> dims (void) const { return dimensions; } - T range_error (const char *fcn, const Array<int>& idx) const; - T& range_error (const char *fcn, const Array<int>& idx); + T range_error (const char *fcn, const Array<int>& ra_idx) const; + T& range_error (const char *fcn, const Array<int>& ra_idx); // No checking of any kind, ever. - T& xelem (const Array<int>& idx) - { return Array<T>::xelem (compute_index (idx)); } + T& xelem (const Array<int>& ra_idx) + { return Array<T>::xelem (compute_index (ra_idx)); } - T xelem (const Array<int>& idx) const - { return Array<T>::xelem (compute_index (idx)); } + T xelem (const Array<int>& ra_idx) const + { return Array<T>::xelem (compute_index (ra_idx)); } // 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 (const Array<int>& idx) + T& checkelem (const Array<int>& ra_idx) { - int i = compute_index (idx); + int i = compute_index (ra_idx); if (i < 0) - return range_error ("ArrayN<T>::checkelem", idx); + return range_error ("ArrayN<T>::checkelem", ra_idx); else return Array<T>::elem (i); } - T& elem (const Array<int>& idx) + T& elem (const Array<int>& ra_idx) { - int i = compute_index (idx); + int i = compute_index (ra_idx); return Array<T>::elem (i); } #if defined (BOUNDS_CHECKING) - T& operator () (const Array<int>& idx) { return checkelem (idx); } + T& operator () (const Array<int>& ra_idx) { return checkelem (ra_idx); } #else - T& operator () (const Array<int>& idx) { return elem (idx); } + T& operator () (const Array<int>& ra_idx) { return elem (ra_idx); } #endif - T checkelem (const Array<int>& idx) const + T checkelem (const Array<int>& ra_idx) const { - int i = compute_index (idx); + int i = compute_index (ra_idx); if (i < 0) - return range_error ("ArrayN<T>::checkelem", idx); + return range_error ("ArrayN<T>::checkelem", ra_idx); else return Array<T>::elem (i); } - T elem (const Array<int>& idx) const + T elem (const Array<int>& ra_idx) const { - int i = compute_index (idx); + int i = compute_index (ra_idx); return Array<T>::elem (i); } #if defined (BOUNDS_CHECKING) - T operator () (const Array<int>& idx) const { return checkelem (idx); } + T operator () (const Array<int>& ra_idx) const { return checkelem (ra_idx); } #else - T operator () (const Array<int>& idx) const { return elem (idx); } + T operator () (const Array<int>& ra_idx) const { return elem (ra_idx); } #endif void resize (const Array<int>& dims); @@ -175,14 +175,14 @@ ArrayN<T>& insert (const ArrayN<T>& a, const Array<int>& dims); #ifdef HEAVYWEIGHT_INDEXING - void maybe_delete_elements (Array<idx_vector>& idx); + void maybe_delete_elements (Array<idx_vector>& ra_idx); ArrayN<T> value (void); - ArrayN<T> index (idx_vector& idx, int resize_ok = 0, + ArrayN<T> index (idx_vector& ra_idx, int resize_ok = 0, const T& rfv = Array<T>::resize_fill_value ()) const; - ArrayN<T> index (Array<idx_vector>& idx, int resize_ok = 0, + ArrayN<T> index (Array<idx_vector>& ra_idx, int resize_ok = 0, const T& rfv = Array<T>::resize_fill_value ()) const; #endif