comparison test/build-sparse-tests.sh @ 19006:2e0613dadfee draft

All calls to "find" use the same generic implementation (bug #42408, 42421) * find.cc: Rewrite. Move generic "find" logic to find.h (Ffind) : Changed calls to find_nonzero_elem_idx to find_templated Added unit test for bug #42421 * Array.cc (and .h) (Array::find): Deleted function. Replaced with find::find(Array) from find.h * Array.h: Added typedef for array_iterator (in nz-iterators.h) as Array::iter_type * DiagArray2.h: Added typedef for diag_iterator (in nz-iterators.h) as DiagArray2::iter_type * PermMatrix.h: Added typedef for perm_iterator (in nz-iterators.h) as PermMatrix::iter_type Also added typedef for bool as PermMatrix::element_type (not octave_idx_type) Added an nnz() function (which is an alias for perm_length) and a perm_elem(i) function for retrieving the ith element of the permutation * Sparse.h: Added typedef for sparse_iterator (in nz-iterators.h) as Sparse::iter_type Added a short comment documenting the the argument to the numel function * idx-vector.cc (idx_vector::idx_mask_rep::as_array): Changed Array.find to find::find(Array) (in find.h) * (new file) find.h * (new file) interp-idx.h: Simple methods for converting between interpreter index type and internal octave_idx_type/row-col pair * (new file) min-with-nnz.h: Fast methods for taking an arbitrary matrix M and an octave_idx_type n and finding min(M.nnz(), n) * (new file) nz-iterators.h: Iterators for traversing (in column-major order) the nonzero elements of any array or matrix backwards or forwards * (new file) direction.h: Generic methods for simplifying code has to deal with a "backwards or forwards" template argument * build-sparse-tests.sh: Removed 5-return-value calls to "find" in unit-tests; Admittedly this commit breaks this "feature" which was undocumented and only partially supported to begin with (ie never worked for full matrices, permutation matrices, or diagonal matrices)
author David Spies <dnspies@gmail.com>
date Tue, 17 Jun 2014 16:41:11 -0600
parents 1b6db9303933
children
comparison
equal deleted inserted replaced
19003:d00f6b09258f 19006:2e0613dadfee
567 567
568 %!assert (as==as) 568 %!assert (as==as)
569 %!assert (as==af) 569 %!assert (as==af)
570 %!assert (af==as) 570 %!assert (af==as)
571 %!test 571 %!test
572 %! [ii,jj,vv,nr,nc] = find (as); 572 %! [ii,jj,vv] = find (as);
573 %! [nr,nc] = size (as);
573 %! assert (af, full (sparse (ii,jj,vv,nr,nc))); 574 %! assert (af, full (sparse (ii,jj,vv,nr,nc)));
574 %!assert (nnz (as), sum (af(:)!=0)) 575 %!assert (nnz (as), sum (af(:)!=0))
575 %!assert (nnz (as), nnz (af)) 576 %!assert (nnz (as), nnz (af))
576 %!assert (issparse (as.')) 577 %!assert (issparse (as.'))
577 %!assert (issparse (as')) 578 %!assert (issparse (as'))
596 %! [i,j,v] = find (as); 597 %! [i,j,v] = find (as);
597 %! [m,n] = size (as); 598 %! [m,n] = size (as);
598 %! x = sparse (i,j,v,m,n); 599 %! x = sparse (i,j,v,m,n);
599 %! assert (x, as); 600 %! assert (x, as);
600 %!test 601 %!test
601 %! [i,j,v,m,n] = find (as); 602 %! [i,j,v] = find (as);
603 %! [m,n] = size (as);
602 %! x = sparse (i,j,v,m,n); 604 %! x = sparse (i,j,v,m,n);
603 %! assert (x, as); 605 %! assert (x, as);
604 %!assert (issparse (horzcat (as,as))); 606 %!assert (issparse (horzcat (as,as)));
605 %!assert (issparse (vertcat (as,as))); 607 %!assert (issparse (vertcat (as,as)));
606 %!assert (issparse (cat (1,as,as))); 608 %!assert (issparse (cat (1,as,as)));