Mercurial > hg > octave-terminal
changeset 3513:6b8d14532d86
[project @ 2000-02-01 22:32:39 by jwe]
author | jwe |
---|---|
date | Tue, 01 Feb 2000 22:32:40 +0000 |
parents | e72d846e6f60 |
children | 1d79338a016c |
files | liboctave/Array-idx.h liboctave/Array2-idx.h liboctave/ChangeLog |
diffstat | 3 files changed, 24 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array-idx.h +++ b/liboctave/Array-idx.h @@ -36,14 +36,14 @@ template <class T> void -Array<T>::set_index (const idx_vector& i) +Array<T>::set_index (const idx_vector& idx_arg) { if (! idx) idx = new idx_vector [max_indices]; if (idx_count < max_indices) { - idx[idx_count++] = i; + idx[idx_count++] = idx_arg; } else {
--- a/liboctave/Array2-idx.h +++ b/liboctave/Array2-idx.h @@ -43,10 +43,7 @@ } else if (n_idx == 1) { - idx_vector *tmp = get_idx (); - idx_vector idx = tmp[0]; - - return index (idx); + return index (idx[0]); } else (*current_liboctave_error_handler) @@ -59,19 +56,19 @@ template <class T> Array2<T> -Array2<T>::index (idx_vector& idx) const +Array2<T>::index (idx_vector& idx_arg) const { Array2<T> retval; int nr = d1; int nc = d2; - int idx_orig_rows = idx.orig_rows (); - int idx_orig_columns = idx.orig_columns (); + int idx_orig_rows = idx_arg.orig_rows (); + int idx_orig_columns = idx_arg.orig_columns (); if (nr == 1 && nc == 1) { - Array<T> tmp = Array<T>::index (idx); + Array<T> tmp = Array<T>::index (idx_arg); int len = tmp.length (); @@ -87,9 +84,9 @@ } else if (nr == 1 || nc == 1) { - int result_is_column_vector = (nc == 1 || idx.is_colon ()); + int result_is_column_vector = (nc == 1 || idx_arg.is_colon ()); - Array<T> tmp = Array<T>::index (idx); + Array<T> tmp = Array<T>::index (idx_arg); int len = tmp.length (); @@ -104,29 +101,29 @@ } } else if (liboctave_dfi_flag - || idx.is_colon () - || (idx.one_zero_only () + || idx_arg.is_colon () + || (idx_arg.one_zero_only () && idx_orig_rows == nr && idx_orig_columns == nc)) { // This code is only for indexing matrices. The vector // cases are handled above. - idx.freeze (nr * nc, "matrix"); + idx_arg.freeze (nr * nc, "matrix"); - if (idx) + if (idx_arg) { int result_nr = idx_orig_rows; int result_nc = idx_orig_columns; - if (idx.is_colon ()) + if (idx_arg.is_colon ()) { result_nr = nr * nc; result_nc = result_nr ? 1 : 0; } - else if (idx.one_zero_only ()) + else if (idx_arg.one_zero_only ()) { - result_nr = idx.ones_count (); + result_nr = idx_arg.ones_count (); result_nc = (result_nr > 0 ? 1 : 0); } @@ -137,7 +134,7 @@ { for (int i = 0; i < result_nr; i++) { - int ii = idx.elem (k++); + int ii = idx_arg.elem (k++); int fr = ii % nr; int fc = (ii - fr) / nr; retval.elem (i, j) = elem (fr, fc); @@ -220,7 +217,7 @@ template <class T> void -Array2<T>::maybe_delete_elements (idx_vector& idx_i) +Array2<T>::maybe_delete_elements (idx_vector& idx_arg) { int nr = d1; int nc = d2; @@ -241,7 +238,7 @@ return; } - if (idx_i.is_colon_equiv (n, 1)) + if (idx_arg.is_colon_equiv (n, 1)) { // Either A(:) = [] or A(idx) = [] with idx enumerating all // elements, so we delete all elements and return [](0x0). To @@ -252,9 +249,9 @@ return; } - idx_i.sort (true); + idx_arg.sort (true); - int num_to_delete = idx_i.length (n); + int num_to_delete = idx_arg.length (n); if (num_to_delete != 0) { @@ -263,7 +260,7 @@ int idx = 0; for (int i = 0; i < n; i++) - if (i == idx_i.elem (idx)) + if (i == idx_arg.elem (idx)) { idx++; new_n--; @@ -280,7 +277,7 @@ idx = 0; for (int i = 0; i < n; i++) { - if (idx < num_to_delete && i == idx_i.elem (idx)) + if (idx < num_to_delete && i == idx_arg.elem (idx)) idx++; else {