Mercurial > hg > octave-terminal
changeset 7197:e1c865f21751
[project @ 2007-11-27 01:38:48 by jwe]
author | jwe |
---|---|
date | Tue, 27 Nov 2007 01:38:49 +0000 |
parents | 9092375e3936 |
children | 4555c116b420 |
files | liboctave/Sparse-op-defs.h scripts/ChangeLog scripts/sparse/spstats.m scripts/statistics/base/mode.m src/ChangeLog test/ChangeLog test/build_sparse_tests.sh test/test_range.m |
diffstat | 8 files changed, 69 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Sparse-op-defs.h +++ b/liboctave/Sparse-op-defs.h @@ -1634,35 +1634,54 @@ } \ else if (nc == 0 && (nr == 0 || (nr == 1 && dim == -1))) \ { \ - retval = RET_TYPE (static_cast<octave_idx_type> (1), \ - static_cast<octave_idx_type> (1), \ - static_cast<octave_idx_type> (1)); \ - retval.cidx(0) = 0; \ - retval.cidx(1) = 1; \ - retval.ridx(0) = 0; \ - retval.data(0) = MT_RESULT; \ + if (MT_RESULT) \ + { \ + retval = RET_TYPE (static_cast<octave_idx_type> (1), \ + static_cast<octave_idx_type> (1), \ + static_cast<octave_idx_type> (1)); \ + retval.cidx(0) = 0; \ + retval.cidx(1) = 1; \ + retval.ridx(0) = 0; \ + retval.data(0) = MT_RESULT; \ + } \ + else \ + retval = RET_TYPE (static_cast<octave_idx_type> (1), \ + static_cast<octave_idx_type> (1), \ + static_cast<octave_idx_type> (0)); \ } \ else if (nr == 0 && (dim == 0 || dim == -1)) \ { \ - retval = RET_TYPE (static_cast<octave_idx_type> (1), nc, nc); \ - retval.cidx (0) = 0; \ - for (octave_idx_type i = 0; i < nc ; i++) \ + if (MT_RESULT) \ { \ - retval.ridx (i) = 0; \ - retval.cidx (i+1) = i; \ - retval.data (i) = MT_RESULT; \ - } \ + retval = RET_TYPE (static_cast<octave_idx_type> (1), nc, nc); \ + retval.cidx (0) = 0; \ + for (octave_idx_type i = 0; i < nc ; i++) \ + { \ + retval.ridx (i) = 0; \ + retval.cidx (i+1) = i; \ + retval.data (i) = MT_RESULT; \ + } \ + } \ + else \ + retval = RET_TYPE (static_cast<octave_idx_type> (1), nc, \ + static_cast<octave_idx_type> (0)); \ } \ else if (nc == 0 && dim == 1) \ { \ - retval = RET_TYPE (nr, static_cast<octave_idx_type> (1), nr); \ - retval.cidx(0) = 0; \ - retval.cidx(1) = nr; \ - for (octave_idx_type i = 0; i < nr; i++) \ - { \ - retval.ridx(i) = i; \ - retval.data(i) = MT_RESULT; \ - } \ + if (MT_RESULT) \ + { \ + retval = RET_TYPE (nr, static_cast<octave_idx_type> (1), nr); \ + retval.cidx(0) = 0; \ + retval.cidx(1) = nr; \ + for (octave_idx_type i = 0; i < nr; i++) \ + { \ + retval.ridx(i) = i; \ + retval.data(i) = MT_RESULT; \ + } \ + } \ + else \ + retval = RET_TYPE (nr, static_cast<octave_idx_type> (1), \ + static_cast<octave_idx_type> (0)); \ } \ else \ retval.resize (nr > 0, nc > 0); \
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,9 @@ 2007-11-26 David Bateman <dbateman@free.fr> + * sparse/spstats.m, statistics/base/mode.m: More care with sparse + return values. + + * plot/plotyy.m: New function * plot/Makefile.in (SOURCES): Add it here. * plot/__go_draw_axes__.m: Force axis margins for plotyy. Set text
--- a/scripts/sparse/spstats.m +++ b/scripts/sparse/spstats.m @@ -59,6 +59,6 @@ %!test %! [n,m,v] = spstats([1 2 1 2 3 4],[2 2 1 1 1 1]); -%! assert(n,[4,2]); -%! assert(m,[10/4,3/2],10*eps); -%! assert(v,[5/3,1/2],10*eps); +%! assert(n,sparse([4,2],1)); +%! assert(m,sparse([10/4,3/2],1),10*eps); +%! assert(v,sparse([5/3,1/2],1),10*eps);
--- a/scripts/statistics/base/mode.m +++ b/scripts/statistics/base/mode.m @@ -105,6 +105,6 @@ %! a = sprandn (32, 32, 0.05); %! [m, f, c] = mode (a); %! [m2, f2, c2] = mode (full (a)); -%! assert (m, m2); -%! assert (f, f2); -%! assert (c, c2); +%! assert (m, sparse (m2, 1)); +%! assert (f, sparse (f2, 1)); +%! assert (c, cellfun (@(x) sparse (1, 1), c2, 'UniformOutput', false));
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2007-11-26 David Bateman <dbateman@free.fr> + * Sparse-op-defs.h (SPARSE_BASE_REDUCTION_OP): Check that the fill + value is not zero before creating the matrices. + * graphics.cc (class axes): Add the {x|y|z}color color property. * graphics.h.in (class axes): ditto.
--- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2007-11-26 David Bateman <dbateman@free.fr> + + * build_sparse_tests.sh: More care with sparse return values. + 2007-10-30 Kim Hansen <kimhanse@gmail.com> * build_sparse_tests.sh: Fix typo.
--- a/test/build_sparse_tests.sh +++ b/test/build_sparse_tests.sh @@ -215,7 +215,7 @@ %!test %! wdbz = warning ("query", "Octave:divide-by-zero"); %! warning ("off", "Octave:divide-by-zero"); -%! assert(sparse(eye(3))/0,sparse(eye(3)/0,1)); +%! assert(full(sparse(eye(3))/0),eye(3)/0); %! warning (wdbz.state, "Octave:divide-by-zero"); EOF @@ -547,14 +547,14 @@ %!assert(spcumprod(as,2),sparse(cumprod(af,2),true)) %!assert(spmin(as),sparse(min(af),true)) -%!assert(spmin(as(:)),min(af(:))) +%!assert(full(spmin(as(:))),min(af(:))) %!assert(spmin(as,[],1),sparse(min(af,[],1),true)) %!assert(spmin(as,[],2),sparse(min(af,[],2),true)) %!assert(spmin(as,[],1),sparse(min(af,[],1),true)) %!assert(spmin(as,0),sparse(min(af,0),true)) %!assert(spmin(as,bs),sparse(min(af,bf),true)) %!assert(spmax(as),sparse(max(af),true)) -%!assert(spmax(as(:)),max(af(:))) +%!assert(full(spmax(as(:))),max(af(:))) %!assert(spmax(as,[],1),sparse(max(af,[],1),true)) %!assert(spmax(as,[],2),sparse(max(af,[],2),true)) %!assert(spmax(as,[],1),sparse(max(af,[],1),true)) @@ -832,10 +832,10 @@ %! assert(ts,sparse(tf,true)); %% Test 'end' keyword -%!assert(as(end),af(end)) -%!assert(as(1,end), af(1,end)) -%!assert(as(end,1), af(end,1)) -%!assert(as(end,end), af(end,end)) +%!assert(full(as(end)), af(end)) +%!assert(full(as(1,end)), af(1,end)) +%!assert(full(as(end,1)), af(end,1)) +%!assert(full(as(end,end)), af(end,end)) %!assert(as(2:end,2:end), sparse(af(2:end,2:end),true)) %!assert(as(1:end-1,1:end-1), sparse(af(1:end-1,1:end-1),true)) EOF
--- a/test/test_range.m +++ b/test/test_range.m @@ -35,8 +35,8 @@ %!assert([ r ; z ], expect) %!assert([ r ; logical(z) ], expect) -%!assert([ r ; sparse(z) ], expect) -%!assert([ r ; sparse(logical(z)) ], expect) +%!assert([ r ; sparse(z) ], sparse (expect, true)) +%!assert([ r ; sparse(logical(z)) ], sparse (expect, true)) %!assert([ r ; int8(z) ], int8(expect)) %!assert([ r ; int16(z) ], int16(expect)) @@ -58,8 +58,8 @@ %!assert([ r ; z ], expect) %!assert([ r ; logical(z) ], expect) -%!assert([ r ; sparse(z) ], expect) -%!assert([ r ; sparse(logical(z)) ], expect) +%!assert([ r ; sparse(z) ], sparse (expect, true)) +%!assert([ r ; sparse(logical(z)) ], sparse (expect, true)) %!assert([ r ; int8(z) ], int8(expect)) %!assert([ r ; int16(z) ], int16(expect))