# HG changeset patch # User jwe # Date 1197392613 0 # Node ID 3f29467c1667bf5c366feedd23510c7691f7226a # Parent c0c6aa5afff45f197cc93dd5993b5ee9f53f84ba [project @ 2007-12-11 17:03:32 by jwe] diff -r c0c6aa5afff4 -r 3f29467c1667 scripts/ChangeLog --- a/scripts/ChangeLog Tue Dec 11 16:57:39 2007 +0000 +++ b/scripts/ChangeLog Tue Dec 11 17:03:33 2007 +0000 @@ -1,5 +1,8 @@ 2007-12-11 David Bateman + * sparse/spstats.m: Drop argument to Fsparse to force mutation. + * statistics/base/mode.m: Ditto. + * plot/__plt_get_axis_arg__.m: Ignore integer valued handles as object handles are all now non integer. diff -r c0c6aa5afff4 -r 3f29467c1667 scripts/sparse/spstats.m --- a/scripts/sparse/spstats.m Tue Dec 11 16:57:39 2007 +0000 +++ b/scripts/sparse/spstats.m Tue Dec 11 17:03:33 2007 +0000 @@ -59,6 +59,6 @@ %!test %! [n,m,v] = spstats([1 2 1 2 3 4],[2 2 1 1 1 1]); -%! 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); +%! assert(n,sparse([4,2])); +%! assert(m,sparse([10/4,3/2]),10*eps); +%! assert(v,sparse([5/3,1/2]),10*eps); diff -r c0c6aa5afff4 -r 3f29467c1667 scripts/statistics/base/mode.m --- a/scripts/statistics/base/mode.m Tue Dec 11 16:57:39 2007 +0000 +++ b/scripts/statistics/base/mode.m Tue Dec 11 17:03:33 2007 +0000 @@ -84,7 +84,11 @@ endif c = cell (sz2); - m = zeros (sz2); + if (issparse (x)) + m = sparse (sz2(1), sz2(2)); + else + m = zeros (sz2); + endif for i = 1 : prod (sz2) c{i} = xs (t2 (:, i) == f(i), i); m (i) = c{i}(1); @@ -105,6 +109,6 @@ %! a = sprandn (32, 32, 0.05); %! [m, f, c] = mode (a); %! [m2, f2, c2] = mode (full (a)); -%! assert (m, sparse (m2, 1)); -%! assert (f, sparse (f2, 1)); -%! assert (c, cellfun (@(x) sparse (1, 1), c2, 'UniformOutput', false)); +%! assert (m, sparse (m2)); +%! assert (f, sparse (f2)); +%! assert (c, cellfun (@(x) sparse (0), c2, 'UniformOutput', false)); diff -r c0c6aa5afff4 -r 3f29467c1667 src/ChangeLog --- a/src/ChangeLog Tue Dec 11 16:57:39 2007 +0000 +++ b/src/ChangeLog Tue Dec 11 17:03:33 2007 +0000 @@ -1,5 +1,8 @@ 2007-12-11 David Bateman + * DLD-FUNCTIONS/sparse.cc (FSparse): Remove the mutate flag, as + default bahavior is now to keep matrix sparse always. + * graphics.cc (axes::properties::properties): Initialize xcolor, ycolor, and zcolor to (0, 0, 0). diff -r c0c6aa5afff4 -r 3f29467c1667 src/DLD-FUNCTIONS/sparse.cc --- a/src/DLD-FUNCTIONS/sparse.cc Tue Dec 11 16:57:39 2007 +0000 +++ b/src/DLD-FUNCTIONS/sparse.cc Tue Dec 11 17:03:33 2007 +0000 @@ -106,13 +106,11 @@ @end deftypefn") { octave_value retval; - bool mutate = false; // WARNING: This function should always use constructions like // retval = new octave_sparse_matrix (sm); // To avoid calling the maybe_mutate function. This is the only - // function that should not call maybe_mutate, or at least only - // in very particular cases. + // function that should not call maybe_mutate int nargin= args.length(); if (nargin < 1 || (nargin == 4 && !args(3).is_string ()) || nargin > 6) @@ -134,11 +132,7 @@ use_bool = args(0).is_bool_type (); } - if (nargin == 2 && ! args(0).is_scalar_type() && args(1).is_scalar_type()) - mutate = (args(1).double_value() != 0.); - - if (nargin == 1 || (nargin == 2 && ! args(0).is_scalar_type() && - args(1).is_scalar_type())) + if (nargin == 1) { octave_value arg = args (0); @@ -355,10 +349,6 @@ } } - // Only called in very particular cases, not the default case - if (mutate) - retval.maybe_mutate (); - return retval; } diff -r c0c6aa5afff4 -r 3f29467c1667 test/ChangeLog --- a/test/ChangeLog Tue Dec 11 16:57:39 2007 +0000 +++ b/test/ChangeLog Tue Dec 11 17:03:33 2007 +0000 @@ -1,3 +1,8 @@ +2007-12-11 David Bateman + + * build_sparse_tests.sh: Drop argument to Fsparse to force mutation. + * test_range.m: Ditto. + 2007-12-10 John W. Eaton * test_nonlin.m: Delete. diff -r c0c6aa5afff4 -r 3f29467c1667 test/build_sparse_tests.sh --- a/test/build_sparse_tests.sh Tue Dec 11 16:57:39 2007 +0000 +++ b/test/build_sparse_tests.sh Tue Dec 11 17:03:33 2007 +0000 @@ -273,27 +273,27 @@ gen_ordering_tests() { cat >>$TESTS <=bf,sparse(af>=bf,true)) -%!assert(bf>=as,sparse(bf>=af,true)) +%!assert(as>=bf,sparse(af>=bf)) +%!assert(bf>=as,sparse(bf>=af)) -%!assert(asbf,sparse(af>bf,true)) -%!assert(bf>as,sparse(bf>af,true)) +%!assert(as>bf,sparse(af>bf)) +%!assert(bf>as,sparse(bf>af)) EOF } gen_sparsesparse_ordering_tests() { cat >>$TESTS <=bs,sparse(af>=bf,true)) -%!assert(asbs,sparse(af>bf,true)) +%!assert(as<=bs,sparse(af<=bf)) +%!assert(as>=bs,sparse(af>=bf)) +%!assert(asbs,sparse(af>bf)) EOF } @@ -301,11 +301,11 @@ gen_elementop_tests() { cat >>$TESTS <>$TESTS <>$TESTS <>$TESTS <>$TESTS +echo "%!assert($1(as),sparse($1(af)))" >>$TESTS } print_real_mapper_test() { @@ -434,7 +434,7 @@ %! warning ("off", "Octave:num-to-str"); %! if isreal(af) %! if ($2) -%! assert($1(as),sparse($1(af),1)) +%! assert($1(as),sparse($1(af))) %! else %! assert($1(as),$1(af)) %! endif @@ -531,36 +531,36 @@ %!assert(!issparse(af)) %!assert(!(issparse(af)&&iscomplex(af))) %!assert(!(issparse(af)&&isreal(af))) -%!assert(spsum(as),sparse(sum(af),true)) -%!assert(spsum(as,1),sparse(sum(af,1),true)) -%!assert(spsum(as,2),sparse(sum(af,2),true)) -%!assert(spcumsum(as),sparse(cumsum(af),true)) -%!assert(spcumsum(as,1),sparse(cumsum(af,1),true)) -%!assert(spcumsum(as,2),sparse(cumsum(af,2),true)) -%!assert(spsumsq(as),sparse(sumsq(af),true)) -%!assert(spsumsq(as,1),sparse(sumsq(af,1),true)) -%!assert(spsumsq(as,2),sparse(sumsq(af,2),true)) -%!assert(spprod(as),sparse(prod(af),true)) -%!assert(spprod(as,1),sparse(prod(af,1),true)) -%!assert(spprod(as,2),sparse(prod(af,2),true)) -%!assert(spcumprod(as),sparse(cumprod(af),true)) -%!assert(spcumprod(as,1),sparse(cumprod(af,1),true)) -%!assert(spcumprod(as,2),sparse(cumprod(af,2),true)) +%!assert(spsum(as),sparse(sum(af))) +%!assert(spsum(as,1),sparse(sum(af,1))) +%!assert(spsum(as,2),sparse(sum(af,2))) +%!assert(spcumsum(as),sparse(cumsum(af))) +%!assert(spcumsum(as,1),sparse(cumsum(af,1))) +%!assert(spcumsum(as,2),sparse(cumsum(af,2))) +%!assert(spsumsq(as),sparse(sumsq(af))) +%!assert(spsumsq(as,1),sparse(sumsq(af,1))) +%!assert(spsumsq(as,2),sparse(sumsq(af,2))) +%!assert(spprod(as),sparse(prod(af))) +%!assert(spprod(as,1),sparse(prod(af,1))) +%!assert(spprod(as,2),sparse(prod(af,2))) +%!assert(spcumprod(as),sparse(cumprod(af))) +%!assert(spcumprod(as,1),sparse(cumprod(af,1))) +%!assert(spcumprod(as,2),sparse(cumprod(af,2))) -%!assert(spmin(as),sparse(min(af),true)) +%!assert(spmin(as),sparse(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(spmin(as,[],1),sparse(min(af,[],1))) +%!assert(spmin(as,[],2),sparse(min(af,[],2))) +%!assert(spmin(as,[],1),sparse(min(af,[],1))) +%!assert(spmin(as,0),sparse(min(af,0))) +%!assert(spmin(as,bs),sparse(min(af,bf))) +%!assert(spmax(as),sparse(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)) -%!assert(spmax(as,0),sparse(max(af,0),true)) -%!assert(spmax(as,bs),sparse(max(af,bf),true)) +%!assert(spmax(as,[],1),sparse(max(af,[],1))) +%!assert(spmax(as,[],2),sparse(max(af,[],2))) +%!assert(spmax(as,[],1),sparse(max(af,[],1))) +%!assert(spmax(as,0),sparse(max(af,0))) +%!assert(spmax(as,bs),sparse(max(af,bf))) %!assert(as==as) %!assert(as==af) @@ -573,11 +573,11 @@ %!assert(issparse(as.')) %!assert(issparse(as')) %!assert(issparse(-as)) -%!assert(~as,sparse(~af,true)) -%!assert(as.', sparse(af.',true)); -%!assert(as', sparse(af',true)); -%!assert(-as, sparse(-af,true)); -%!assert(~as, sparse(~af,true)); +%!assert(~as,sparse(~af)) +%!assert(as.', sparse(af.')); +%!assert(as', sparse(af')); +%!assert(-as, sparse(-af)); +%!assert(~as, sparse(~af)); %!error [i,j]=size(af);as(i-1,j+1); %!error [i,j]=size(af);as(i+1,j-1); %!test @@ -796,53 +796,53 @@ %% Point tests %!test idx=ridx(:)+rows(as)*(cidx(:)-1); -%!assert(sparse(as(idx),true),sparse(af(idx),true)); -%!assert(as(idx),sparse(af(idx),true)); -%!assert(as(idx'),sparse(af(idx'),true)); -%!assert(as(flipud(idx(:))),sparse(af(flipud(idx(:))),true)) -%!assert(as([idx,idx]),sparse(af([idx,idx]),true)); +%!assert(sparse(as(idx)),sparse(af(idx))); +%!assert(as(idx),sparse(af(idx))); +%!assert(as(idx'),sparse(af(idx'))); +%!assert(as(flipud(idx(:))),sparse(af(flipud(idx(:))))) +%!assert(as([idx,idx]),sparse(af([idx,idx]))); %!error(as(reshape([idx;idx],[1,length(idx),2]))); %% Slice tests -%!assert(as(ridx,cidx), sparse(af(ridx,cidx),true)) -%!assert(as(ridx,:), sparse(af(ridx,:),true)) -%!assert(as(:,cidx), sparse(af(:,cidx),true)) -%!assert(as(:,:), sparse(af(:,:),true)) -%!assert(as((size(as,1):-1:1),:),sparse(af((size(af,1):-1:1),:),true)) -%!assert(as(:,(size(as,2):-1:1)),sparse(af(:,(size(af,2):-1:1)),true)) +%!assert(as(ridx,cidx), sparse(af(ridx,cidx))) +%!assert(as(ridx,:), sparse(af(ridx,:))) +%!assert(as(:,cidx), sparse(af(:,cidx))) +%!assert(as(:,:), sparse(af(:,:))) +%!assert(as((size(as,1):-1:1),:),sparse(af((size(af,1):-1:1),:))) +%!assert(as(:,(size(as,2):-1:1)),sparse(af(:,(size(af,2):-1:1)))) %% Assignment test %!test %! ts=as;ts(:,:)=ts(fliplr(1:size(as,1)),:); %! tf=af;tf(:,:)=tf(fliplr(1:size(af,1)),:); -%! assert(ts,sparse(tf,true)); +%! assert(ts,sparse(tf)); %!test %! ts=as;ts(fliplr(1:size(as,1)),:)=ts; %! tf=af;tf(fliplr(1:size(af,1)),:)=tf; -%! assert(ts,sparse(tf,true)); +%! assert(ts,sparse(tf)); %!test %! ts=as;ts(:,fliplr(1:size(as,2)))=ts; %! tf=af;tf(:,fliplr(1:size(af,2)))=tf; -%! assert(ts,sparse(tf,true)); +%! assert(ts,sparse(tf)); %!test %! ts(fliplr(1:size(as,1)))=as(:,1);tf(fliplr(1:size(af,1)))=af(:,1); -%! assert(ts,sparse(tf,true)); +%! assert(ts,sparse(tf)); %% Deletion tests %!test %! ts=as;ts(1,:)=[];tf=af;tf(1,:)=[]; -%! assert(ts,sparse(tf,true)); +%! assert(ts,sparse(tf)); %!test %! ts=as;ts(:,1)=[];tf=af;tf(:,1)=[]; -%! assert(ts,sparse(tf,true)); +%! assert(ts,sparse(tf)); %% Test 'end' keyword %!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)) +%!assert(as(2:end,2:end), sparse(af(2:end,2:end))) +%!assert(as(1:end-1,1:end-1), sparse(af(1:end-1,1:end-1))) EOF } @@ -914,9 +914,9 @@ %! tcf = tf + tf'; tcs = sparse(tcf); %! xf = diag(1:n) + fliplr(diag(1:n)).*beta; xs = sparse(xf); %!assert(ds\xf,df\xf,1e-10); -%!assert(ds\xs,sparse(df\xf,1),1e-10); +%!assert(ds\xs,sparse(df\xf),1e-10); %!assert(pds\xf,pdf\xf,1e-10); -%!assert(pds\xs,sparse(pdf\xf,1),1e-10); +%!assert(pds\xs,sparse(pdf\xf),1e-10); %!assert(ls\xf,lf\xf,1e-10); %!assert(sparse(ls\xs),sparse(lf\xf),1e-10); %!testif HAVE_UMFPACK @@ -973,24 +973,24 @@ %! xf = beta * ones(10,2); %! xs = speye(10,10); %!assert(ds\xf,df\xf,100*eps) -%!assert(ds\xs,sparse(df\xs,true),100*eps) +%!assert(ds\xs,sparse(df\xs),100*eps) %!test %! pds = ds([2,1,3:10],:); %! pdf = full(pds); %!assert(pds\xf,pdf\xf,100*eps) -%!assert(pds\xs,sparse(pdf\xs,true),100*eps) +%!assert(pds\xs,sparse(pdf\xs),100*eps) %!test %! ds = alpha * spdiags([1:11]',0,11,10); %! df = full(ds); %! xf = beta * ones(11,2); %! xs = speye(11,11); %!assert(ds\xf,df\xf,100*eps) -%!assert(ds\xs,sparse(df\xs,true),100*eps) +%!assert(ds\xs,sparse(df\xs),100*eps) %!test %! pds = ds([2,1,3:11],:); %! pdf = full(pds); %!assert(pds\xf,pdf\xf,100*eps) -%!assert(pds\xs,sparse(pdf\xs,true),100*eps) +%!assert(pds\xs,sparse(pdf\xs),100*eps) %!test %! us = alpha*[[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]; %!testif HAVE_UMFPACK diff -r c0c6aa5afff4 -r 3f29467c1667 test/test_range.m --- a/test/test_range.m Tue Dec 11 16:57:39 2007 +0000 +++ b/test/test_range.m Tue Dec 11 17:03:33 2007 +0000 @@ -35,8 +35,8 @@ %!assert([ r ; z ], expect) %!assert([ r ; logical(z) ], expect) -%!assert([ r ; sparse(z) ], sparse (expect, true)) -%!assert([ r ; sparse(logical(z)) ], sparse (expect, true)) +%!assert([ r ; sparse(z) ], sparse (expect)) +%!assert([ r ; sparse(logical(z)) ], sparse (expect)) %!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) ], sparse (expect, true)) -%!assert([ r ; sparse(logical(z)) ], sparse (expect, true)) +%!assert([ r ; sparse(z) ], sparse (expect)) +%!assert([ r ; sparse(logical(z)) ], sparse (expect)) %!assert([ r ; int8(z) ], int8(expect)) %!assert([ r ; int16(z) ], int16(expect))