Mercurial > hg > octave-lojdl
changeset 1130:65430ec9a4aa
[project @ 1995-02-22 13:32:29 by jwe]
author | jwe |
---|---|
date | Wed, 22 Feb 1995 13:33:31 +0000 |
parents | 32fbe094cc10 |
children | 8fa4dc6a6068 |
files | liboctave/idx-vector.cc src/tc-rep-idx.cc |
diffstat | 2 files changed, 44 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/idx-vector.cc +++ b/liboctave/idx-vector.cc @@ -54,7 +54,7 @@ min_val = a.min_val; } else - data = (int *) 0; + data = 0; } static inline int @@ -77,7 +77,7 @@ if (nr == 0 || nc == 0) { len = 0; - data = (int *) 0; + data =0; num_zeros = 0; num_ones = 0; one_zero = 0; @@ -128,7 +128,7 @@ } else if (len == 0) { - data = (int *) 0; + data = 0; num_zeros = 0; num_ones = 0; one_zero = 0; @@ -203,16 +203,7 @@ if (one_zero && z_len == len) { - if (num_zeros == len) - { - delete [] data; - len = 0; - data = (int *) 0; - num_zeros = 0; - num_ones = 0; - one_zero = 0; - } - else if (num_ones != len || user_pref.prefer_zero_one_indexing) + if (num_ones != len || user_pref.prefer_zero_one_indexing) convert_one_zero_to_idx (); } else if (min_val < 0) @@ -246,6 +237,7 @@ max_val = 0; min_val = 0; delete [] data; + data = 0; } else {
--- a/src/tc-rep-idx.cc +++ b/src/tc-rep-idx.cc @@ -556,7 +556,45 @@ int result_size = iv.length (); - if (nc == 1 || (nr != 1 && iv.one_zero_only ())) +// XXX FIXME XXX -- there is way too much duplicate code here... + + if (iv.one_zero_only ()) + { + if (iv.ones_count () == 0) + { + retval = Matrix (); + } + else + { + if (nr == 1) + { + CRMATRIX (m, cm, 1, result_size); + + for (int i = 0; i < result_size; i++) + { + int idx = iv.elem (i); + CRMATRIX_ASSIGN_ELEM (m, cm, 0, i, cop_out [idx], + c_cop_out [idx], real_type); + } + + ASSIGN_CRMATRIX_TO (retval, m, cm); + } + else + { + CRMATRIX (m, cm, result_size, 1); + + for (int i = 0; i < result_size; i++) + { + int idx = iv.elem (i); + CRMATRIX_ASSIGN_ELEM (m, cm, i, 0, cop_out [idx], + c_cop_out [idx], real_type); + } + + ASSIGN_CRMATRIX_TO (retval, m, cm); + } + } + } + else if (nc == 1) { CRMATRIX (m, cm, result_size, 1);