Mercurial > hg > octave-nkf
diff liboctave/Sparse.cc @ 14427:d07e989686b0
Use Octave coding conventions in liboctave %!test blocks
* Array.cc, CMatrix.cc, Sparse.cc, dMatrix.cc, fCMatrix.cc, fMatrix.cc,
oct-inttypes.cc: Use Octave coding conventions in liboctave %!test blocks
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 02 Mar 2012 22:13:16 -0800 |
parents | 72c96de7a403 |
children | 12ccdce2c216 |
line wrap: on
line diff
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -2571,7 +2571,7 @@ * Tests * -%!function x = set_slice(x, dim, slice, arg) +%!function x = set_slice (x, dim, slice, arg) %! switch dim %! case 11 %! x(slice) = 2; @@ -2580,151 +2580,151 @@ %! case 22 %! x(:, slice) = 2; %! otherwise -%! error("invalid dim, '%d'", dim); +%! error ("invalid dim, '%d'", dim); %! endswitch -%! endfunction +%!endfunction -%!function x = set_slice2(x, dim, slice) +%!function x = set_slice2 (x, dim, slice) %! switch dim %! case 11 -%! x(slice) = 2 * ones (size(slice)); +%! x(slice) = 2 * ones (size (slice)); %! case 21 -%! x(slice, :) = 2 * ones (length(slice), columns (x)); +%! x(slice, :) = 2 * ones (length (slice), columns (x)); %! case 22 -%! x(:, slice) = 2 * ones (rows (x), length(slice)); +%! x(:, slice) = 2 * ones (rows (x), length (slice)); %! otherwise -%! error("invalid dim, '%d'", dim); +%! error ("invalid dim, '%d'", dim); %! endswitch -%! endfunction +%!endfunction -%!function test_sparse_slice(size, dim, slice) -%! x = ones(size); -%! s = set_slice(sparse(x), dim, slice); -%! f = set_slice(x, dim, slice); +%!function test_sparse_slice (size, dim, slice) +%! x = ones (size); +%! s = set_slice (sparse (x), dim, slice); +%! f = set_slice (x, dim, slice); %! assert (nnz(s), nnz(f)); -%! assert(full(s), f); -%! s = set_slice2(sparse(x), dim, slice); -%! f = set_slice2(x, dim, slice); +%! assert (full(s), f); +%! s = set_slice2 (sparse(x), dim, slice); +%! f = set_slice2 (x, dim, slice); %! assert (nnz(s), nnz(f)); -%! assert(full(s), f); -%! endfunction +%! assert (full(s), f); +%!endfunction #### 1d indexing ## size = [2 0] -%!test test_sparse_slice([2 0], 11, []); -%!assert(set_slice(sparse(ones([2 0])), 11, 1), sparse([2 0]')); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 11, 2), sparse([0 2]')); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 11, 3), sparse([0 0; 2 0]')); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 11, 4), sparse([0 0; 0 2]')); # sparse different from full +%!test test_sparse_slice ([2 0], 11, []); +%!assert (set_slice (sparse (ones ([2 0])), 11, 1), sparse ([2 0]')) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 11, 2), sparse ([0 2]')) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 11, 3), sparse ([0 0; 2 0]')) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 11, 4), sparse ([0 0; 0 2]')) # sparse different from full ## size = [0 2] -%!test test_sparse_slice([0 2], 11, []); -%!assert(set_slice(sparse(ones([0 2])), 11, 1), sparse([2 0])); # sparse different from full -%!test test_sparse_slice([0 2], 11, 2); -%!test test_sparse_slice([0 2], 11, 3); -%!test test_sparse_slice([0 2], 11, 4); -%!test test_sparse_slice([0 2], 11, [4, 4]); +%!test test_sparse_slice ([0 2], 11, []); +%!assert (set_slice (sparse (ones ([0 2])), 11, 1), sparse ([2 0])) # sparse different from full +%!test test_sparse_slice ([0 2], 11, 2); +%!test test_sparse_slice ([0 2], 11, 3); +%!test test_sparse_slice ([0 2], 11, 4); +%!test test_sparse_slice ([0 2], 11, [4, 4]); ## size = [2 1] -%!test test_sparse_slice([2 1], 11, []); -%!test test_sparse_slice([2 1], 11, 1); -%!test test_sparse_slice([2 1], 11, 2); -%!test test_sparse_slice([2 1], 11, 3); -%!test test_sparse_slice([2 1], 11, 4); -%!test test_sparse_slice([2 1], 11, [4, 4]); +%!test test_sparse_slice ([2 1], 11, []); +%!test test_sparse_slice ([2 1], 11, 1); +%!test test_sparse_slice ([2 1], 11, 2); +%!test test_sparse_slice ([2 1], 11, 3); +%!test test_sparse_slice ([2 1], 11, 4); +%!test test_sparse_slice ([2 1], 11, [4, 4]); ## size = [1 2] -%!test test_sparse_slice([1 2], 11, []); -%!test test_sparse_slice([1 2], 11, 1); -%!test test_sparse_slice([1 2], 11, 2); -%!test test_sparse_slice([1 2], 11, 3); -%!test test_sparse_slice([1 2], 11, 4); -%!test test_sparse_slice([1 2], 11, [4, 4]); +%!test test_sparse_slice ([1 2], 11, []); +%!test test_sparse_slice ([1 2], 11, 1); +%!test test_sparse_slice ([1 2], 11, 2); +%!test test_sparse_slice ([1 2], 11, 3); +%!test test_sparse_slice ([1 2], 11, 4); +%!test test_sparse_slice ([1 2], 11, [4, 4]); ## size = [2 2] -%!test test_sparse_slice([2 2], 11, []); -%!test test_sparse_slice([2 2], 11, 1); -%!test test_sparse_slice([2 2], 11, 2); -%!test test_sparse_slice([2 2], 11, 3); -%!test test_sparse_slice([2 2], 11, 4); -%!test test_sparse_slice([2 2], 11, [4, 4]); +%!test test_sparse_slice ([2 2], 11, []); +%!test test_sparse_slice ([2 2], 11, 1); +%!test test_sparse_slice ([2 2], 11, 2); +%!test test_sparse_slice ([2 2], 11, 3); +%!test test_sparse_slice ([2 2], 11, 4); +%!test test_sparse_slice ([2 2], 11, [4, 4]); # These 2 errors are the same as in the full case -%!error id=Octave:invalid-resize set_slice(sparse(ones([2 2])), 11, 5); -%!error id=Octave:invalid-resize set_slice(sparse(ones([2 2])), 11, 6); +%!error id=Octave:invalid-resize set_slice (sparse (ones ([2 2])), 11, 5) +%!error id=Octave:invalid-resize set_slice (sparse (ones ([2 2])), 11, 6) #### 2d indexing ## size = [2 0] -%!test test_sparse_slice([2 0], 21, []); -%!test test_sparse_slice([2 0], 21, 1); -%!test test_sparse_slice([2 0], 21, 2); -%!test test_sparse_slice([2 0], 21, [2,2]); -%!assert(set_slice(sparse(ones([2 0])), 21, 3), sparse(3,0)); -%!assert(set_slice(sparse(ones([2 0])), 21, 4), sparse(4,0)); -%!test test_sparse_slice([2 0], 22, []); -%!test test_sparse_slice([2 0], 22, 1); -%!test test_sparse_slice([2 0], 22, 2); -%!test test_sparse_slice([2 0], 22, [2,2]); -%!assert(set_slice(sparse(ones([2 0])), 22, 3), sparse([0 0 2;0 0 2])); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 22, 4), sparse([0 0 0 2;0 0 0 2])); # sparse different from full +%!test test_sparse_slice ([2 0], 21, []); +%!test test_sparse_slice ([2 0], 21, 1); +%!test test_sparse_slice ([2 0], 21, 2); +%!test test_sparse_slice ([2 0], 21, [2,2]); +%!assert (set_slice (sparse (ones ([2 0])), 21, 3), sparse (3,0)) +%!assert (set_slice (sparse (ones ([2 0])), 21, 4), sparse (4,0)) +%!test test_sparse_slice ([2 0], 22, []); +%!test test_sparse_slice ([2 0], 22, 1); +%!test test_sparse_slice ([2 0], 22, 2); +%!test test_sparse_slice ([2 0], 22, [2,2]); +%!assert (set_slice (sparse (ones ([2 0])), 22, 3), sparse ([0 0 2;0 0 2])) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 22, 4), sparse ([0 0 0 2;0 0 0 2])) # sparse different from full ## size = [0 2] -%!test test_sparse_slice([0 2], 21, []); -%!test test_sparse_slice([0 2], 21, 1); -%!test test_sparse_slice([0 2], 21, 2); -%!test test_sparse_slice([0 2], 21, [2,2]); -%!assert(set_slice(sparse(ones([0 2])), 21, 3), sparse([0 0;0 0;2 2])); # sparse different from full -%!assert(set_slice(sparse(ones([0 2])), 21, 4), sparse([0 0;0 0;0 0;2 2])); # sparse different from full -%!test test_sparse_slice([0 2], 22, []); -%!test test_sparse_slice([0 2], 22, 1); -%!test test_sparse_slice([0 2], 22, 2); -%!test test_sparse_slice([0 2], 22, [2,2]); -%!assert(set_slice(sparse(ones([0 2])), 22, 3), sparse(0,3)); -%!assert(set_slice(sparse(ones([0 2])), 22, 4), sparse(0,4)); +%!test test_sparse_slice ([0 2], 21, []); +%!test test_sparse_slice ([0 2], 21, 1); +%!test test_sparse_slice ([0 2], 21, 2); +%!test test_sparse_slice ([0 2], 21, [2,2]); +%!assert (set_slice (sparse (ones ([0 2])), 21, 3), sparse ([0 0;0 0;2 2])) # sparse different from full +%!assert (set_slice (sparse (ones ([0 2])), 21, 4), sparse ([0 0;0 0;0 0;2 2])) # sparse different from full +%!test test_sparse_slice ([0 2], 22, []); +%!test test_sparse_slice ([0 2], 22, 1); +%!test test_sparse_slice ([0 2], 22, 2); +%!test test_sparse_slice ([0 2], 22, [2,2]); +%!assert (set_slice (sparse (ones ([0 2])), 22, 3), sparse (0,3)) +%!assert (set_slice (sparse (ones ([0 2])), 22, 4), sparse (0,4)) ## size = [2 1] -%!test test_sparse_slice([2 1], 21, []); -%!test test_sparse_slice([2 1], 21, 1); -%!test test_sparse_slice([2 1], 21, 2); -%!test test_sparse_slice([2 1], 21, [2,2]); -%!test test_sparse_slice([2 1], 21, 3); -%!test test_sparse_slice([2 1], 21, 4); -%!test test_sparse_slice([2 1], 22, []); -%!test test_sparse_slice([2 1], 22, 1); -%!test test_sparse_slice([2 1], 22, 2); -%!test test_sparse_slice([2 1], 22, [2,2]); -%!test test_sparse_slice([2 1], 22, 3); -%!test test_sparse_slice([2 1], 22, 4); +%!test test_sparse_slice ([2 1], 21, []); +%!test test_sparse_slice ([2 1], 21, 1); +%!test test_sparse_slice ([2 1], 21, 2); +%!test test_sparse_slice ([2 1], 21, [2,2]); +%!test test_sparse_slice ([2 1], 21, 3); +%!test test_sparse_slice ([2 1], 21, 4); +%!test test_sparse_slice ([2 1], 22, []); +%!test test_sparse_slice ([2 1], 22, 1); +%!test test_sparse_slice ([2 1], 22, 2); +%!test test_sparse_slice ([2 1], 22, [2,2]); +%!test test_sparse_slice ([2 1], 22, 3); +%!test test_sparse_slice ([2 1], 22, 4); ## size = [1 2] -%!test test_sparse_slice([1 2], 21, []); -%!test test_sparse_slice([1 2], 21, 1); -%!test test_sparse_slice([1 2], 21, 2); -%!test test_sparse_slice([1 2], 21, [2,2]); -%!test test_sparse_slice([1 2], 21, 3); -%!test test_sparse_slice([1 2], 21, 4); -%!test test_sparse_slice([1 2], 22, []); -%!test test_sparse_slice([1 2], 22, 1); -%!test test_sparse_slice([1 2], 22, 2); -%!test test_sparse_slice([1 2], 22, [2,2]); -%!test test_sparse_slice([1 2], 22, 3); -%!test test_sparse_slice([1 2], 22, 4); +%!test test_sparse_slice ([1 2], 21, []); +%!test test_sparse_slice ([1 2], 21, 1); +%!test test_sparse_slice ([1 2], 21, 2); +%!test test_sparse_slice ([1 2], 21, [2,2]); +%!test test_sparse_slice ([1 2], 21, 3); +%!test test_sparse_slice ([1 2], 21, 4); +%!test test_sparse_slice ([1 2], 22, []); +%!test test_sparse_slice ([1 2], 22, 1); +%!test test_sparse_slice ([1 2], 22, 2); +%!test test_sparse_slice ([1 2], 22, [2,2]); +%!test test_sparse_slice ([1 2], 22, 3); +%!test test_sparse_slice ([1 2], 22, 4); ## size = [2 2] -%!test test_sparse_slice([2 2], 21, []); -%!test test_sparse_slice([2 2], 21, 1); -%!test test_sparse_slice([2 2], 21, 2); -%!test test_sparse_slice([2 2], 21, [2,2]); -%!test test_sparse_slice([2 2], 21, 3); -%!test test_sparse_slice([2 2], 21, 4); -%!test test_sparse_slice([2 2], 22, []); -%!test test_sparse_slice([2 2], 22, 1); -%!test test_sparse_slice([2 2], 22, 2); -%!test test_sparse_slice([2 2], 22, [2,2]); -%!test test_sparse_slice([2 2], 22, 3); -%!test test_sparse_slice([2 2], 22, 4); +%!test test_sparse_slice ([2 2], 21, []); +%!test test_sparse_slice ([2 2], 21, 1); +%!test test_sparse_slice ([2 2], 21, 2); +%!test test_sparse_slice ([2 2], 21, [2,2]); +%!test test_sparse_slice ([2 2], 21, 3); +%!test test_sparse_slice ([2 2], 21, 4); +%!test test_sparse_slice ([2 2], 22, []); +%!test test_sparse_slice ([2 2], 22, 1); +%!test test_sparse_slice ([2 2], 22, 2); +%!test test_sparse_slice ([2 2], 22, [2,2]); +%!test test_sparse_slice ([2 2], 22, 3); +%!test test_sparse_slice ([2 2], 22, 4); */