Mercurial > hg > octave-terminal
changeset 12030:20a9a8180e33 release-3-2-x
fix sparse +- diag operations
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 02 Jul 2009 08:21:50 +0200 |
parents | ee264f77eaed |
children | 3335e82622ba |
files | liboctave/ChangeLog liboctave/Sparse-diag-op-defs.h |
diffstat | 2 files changed, 36 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2009-07-02 Jaroslav Hajek <highegg@gmail.com> + + * Sparse-diag-op-defs.h (inner_do_add_sm_dm): Rewrite to ensure + ordering of row indices. + 2009-06-26 Michael Goffioul <michael.goffioul@gmail.com> * pathsearch.h (class dir_path::static_members): Decorate with
--- a/liboctave/Sparse-diag-op-defs.h +++ b/liboctave/Sparse-diag-op-defs.h @@ -134,26 +134,38 @@ { OCTAVE_QUIT; const octave_idx_type colend = a.cidx (j+1); - bool found_diag = false; r.xcidx (j) = k; - for (octave_idx_type k_src = a.cidx (j); k_src < colend; ++k_src, ++k) - { - const octave_idx_type i = a.ridx (k_src); - r.xridx (k) = i; - if (i != j) - r.xdata (k) = opa (a.data (k_src)); - else - { - r.xdata (k) = opa (a.data (k_src)) + opd (d.dgelem (j)); - found_diag = true; - } - } - if (!found_diag) - { - r.xridx (k) = j; - r.xdata (k) = opd (d.dgelem (j)); - ++k; - } + octave_idx_type k_src = a.cidx (j), k_split; + + for (k_split = k_src; k_split < colend; k_split++) + if (a.ridx (k_split) >= j) + break; + + for (; k_src < k_split; k_src++, k++) + { + r.xridx (k) = a.ridx (k_src); + r.xdata (k) = opa (a.data (k_src)); + } + + if (k_src < colend && a.ridx (k_src) == j) + { + r.xridx (k) = j; + r.xdata (k) = opa (a.data (k_src)) + opd (d.dgelem (j)); + k++; k_src++; + } + else + { + r.xridx (k) = j; + r.xdata (k) = opd (d.dgelem (j)); + k++; + } + + for (; k_src < colend; k_src++, k++) + { + r.xridx (k) = a.ridx (k_src); + r.xdata (k) = opa (a.data (k_src)); + } + } r.xcidx (nc) = k;