Mercurial > hg > octave-nkf
changeset 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 | e28a1723d5a2 |
children | 099bd779466c |
files | liboctave/Array.cc liboctave/CMatrix.cc liboctave/Sparse.cc liboctave/dMatrix.cc liboctave/fCMatrix.cc liboctave/fMatrix.cc liboctave/oct-inttypes.cc |
diffstat | 7 files changed, 215 insertions(+), 209 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -1645,24 +1645,24 @@ %! m9 = reshape (1 : 9*8, 8, 9); %! mt9 = [mt8; 65:72]; -%!assert(m7', mt7) -%!assert((1i*m7).', 1i * mt7) -%!assert((1i*m7)', conj (1i * mt7)) -%!assert(m8', mt8) -%!assert((1i*m8).', 1i * mt8) -%!assert((1i*m8)', conj (1i * mt8)) -%!assert(m9', mt9) -%!assert((1i*m9).', 1i * mt9) -%!assert((1i*m9)', conj (1i * mt9)) -%!assert([m7, m8; m7, m8]', [mt7, mt7; mt8, mt8]) -%!assert((1i*[m7, m8; m7, m8]).', 1i * [mt7, mt7; mt8, mt8]) -%!assert((1i*[m7, m8; m7, m8])', conj (1i * [mt7, mt7; mt8, mt8])) -%!assert([m8, m8; m8, m8]', [mt8, mt8; mt8, mt8]) -%!assert((1i*[m8, m8; m8, m8]).', 1i * [mt8, mt8; mt8, mt8]) -%!assert((1i*[m8, m8; m8, m8])', conj (1i * [mt8, mt8; mt8, mt8])) -%!assert([m9, m8; m9, m8]', [mt9, mt9; mt8, mt8]) -%!assert((1i*[m9, m8; m9, m8]).', 1i * [mt9, mt9; mt8, mt8]) -%!assert((1i*[m9, m8; m9, m8])', conj (1i * [mt9, mt9; mt8, mt8])) +%!assert (m7', mt7) +%!assert ((1i*m7).', 1i * mt7) +%!assert ((1i*m7)', conj (1i * mt7)) +%!assert (m8', mt8) +%!assert ((1i*m8).', 1i * mt8) +%!assert ((1i*m8)', conj (1i * mt8)) +%!assert (m9', mt9) +%!assert ((1i*m9).', 1i * mt9) +%!assert ((1i*m9)', conj (1i * mt9)) +%!assert ([m7, m8; m7, m8]', [mt7, mt7; mt8, mt8]) +%!assert ((1i*[m7, m8; m7, m8]).', 1i * [mt7, mt7; mt8, mt8]) +%!assert ((1i*[m7, m8; m7, m8])', conj (1i * [mt7, mt7; mt8, mt8])) +%!assert ([m8, m8; m8, m8]', [mt8, mt8; mt8, mt8]) +%!assert ((1i*[m8, m8; m8, m8]).', 1i * [mt8, mt8; mt8, mt8]) +%!assert ((1i*[m8, m8; m8, m8])', conj (1i * [mt8, mt8; mt8, mt8])) +%!assert ([m9, m8; m9, m8]', [mt9, mt9; mt8, mt8]) +%!assert ((1i*[m9, m8; m9, m8]).', 1i * [mt9, mt9; mt8, mt8]) +%!assert ((1i*[m9, m8; m9, m8])', conj (1i * [mt9, mt9; mt8, mt8])) */
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -3702,25 +3702,27 @@ return ComplexMatrix (m) * a; } -/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests -%!assert([1+i 2+i 3+i] * [ 4+i ; 5+i ; 6+i], 29+21i, 1e-14) -%!assert([1+i 2+i ; 3+i 4+i ] * [5+i ; 6+i], [15 + 14i ; 37 + 18i], 1e-14) -%!assert([1+i 2+i ; 3+i 4+i ] * [5+i 6+i ; 7+i 8+i], [17 + 15i 20 + 17i; 41 + 19i 48 + 21i], 1e-14) -%!assert([1 i]*[i 0]', -i); -*/ - -/* Test some simple identities +/* + +## Simple Dot Product, Matrix-Vector, and Matrix-Matrix Unit tests +%!assert ([1+i 2+i 3+i] * [ 4+i ; 5+i ; 6+i], 29+21i, 1e-14) +%!assert ([1+i 2+i ; 3+i 4+i ] * [5+i ; 6+i], [15 + 14i ; 37 + 18i], 1e-14) +%!assert ([1+i 2+i ; 3+i 4+i ] * [5+i 6+i ; 7+i 8+i], [17 + 15i 20 + 17i; 41 + 19i 48 + 21i], 1e-14) +%!assert ([1 i]*[i 0]', -i); + +## Test some simple identities %!shared M, cv, rv -%! M = randn(10,10)+i*rand(10,10); -%! cv = randn(10,1)+i*rand(10,1); -%! rv = randn(1,10)+i*rand(1,10); -%!assert([M*cv,M*cv],M*[cv,cv],1e-14) -%!assert([M.'*cv,M.'*cv],M.'*[cv,cv],1e-14) -%!assert([M'*cv,M'*cv],M'*[cv,cv],1e-14) -%!assert([rv*M;rv*M],[rv;rv]*M,1e-14) -%!assert([rv*M.';rv*M.'],[rv;rv]*M.',1e-14) -%!assert([rv*M';rv*M'],[rv;rv]*M',1e-14) -%!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) +%! M = randn (10,10) + i*rand (10,10); +%! cv = randn (10,1) + i*rand (10,1); +%! rv = randn (1,10) + i*rand (1,10); +%!assert ([M*cv,M*cv], M*[cv,cv], 1e-14) +%!assert ([M.'*cv,M.'*cv], M.'*[cv,cv], 1e-14) +%!assert ([M'*cv,M'*cv], M'*[cv,cv], 1e-14) +%!assert ([rv*M;rv*M], [rv;rv]*M, 1e-14) +%!assert ([rv*M.';rv*M.'], [rv;rv]*M.', 1e-14) +%!assert ([rv*M';rv*M'], [rv;rv]*M', 1e-14) +%!assert (2*rv*cv, [rv,rv]*[cv;cv], 1e-14) + */ static inline char
--- 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); */
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -3113,26 +3113,28 @@ // matrix by matrix -> matrix operations -/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests -%!assert([1 2 3] * [ 4 ; 5 ; 6], 32, 1e-14) -%!assert([1 2 ; 3 4 ] * [5 ; 6], [17 ; 39 ], 1e-14) -%!assert([1 2 ; 3 4 ] * [5 6 ; 7 8], [19 22; 43 50], 1e-14) -*/ - -/* Test some simple identities +/* + +## Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests +%!assert ([1 2 3] * [ 4 ; 5 ; 6], 32, 1e-14) +%!assert ([1 2 ; 3 4 ] * [5 ; 6], [17 ; 39 ], 1e-14) +%!assert ([1 2 ; 3 4 ] * [5 6 ; 7 8], [19 22; 43 50], 1e-14) + +## Test some simple identities %!shared M, cv, rv, Mt, rvt -%! M = randn(10,10)+100*eye(10,10); +%! M = randn (10,10) + 100*eye (10,10); %! Mt = M'; -%! cv = randn(10,1); -%! rv = randn(1,10); +%! cv = randn (10,1); +%! rv = randn (1,10); %! rvt = rv'; -%!assert([M*cv,M*cv],M*[cv,cv],1e-13) -%!assert([M'*cv,M'*cv],M'*[cv,cv],1e-13) -%!assert([rv*M;rv*M],[rv;rv]*M,1e-13) -%!assert([rv*M';rv*M'],[rv;rv]*M',1e-13) -%!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-13) -%!assert(M'\cv,Mt\cv,1e-14) -%!assert(M'\rv',Mt\rvt,1e-14) +%!assert ([M*cv,M*cv], M*[cv,cv], 1e-13) +%!assert ([M'*cv,M'*cv], M'*[cv,cv], 1e-13) +%!assert ([rv*M;rv*M], [rv;rv]*M, 1e-13) +%!assert ([rv*M';rv*M'], [rv;rv]*M', 1e-13) +%!assert (2*rv*cv, [rv,rv]*[cv;cv], 1e-13) +%!assert (M'\cv, Mt\cv, 1e-14) +%!assert (M'\rv', Mt\rvt, 1e-14) + */ static inline char
--- a/liboctave/fCMatrix.cc +++ b/liboctave/fCMatrix.cc @@ -3698,25 +3698,27 @@ return m * FloatComplexMatrix (a); } -/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests -%!assert(single([1+i 2+i 3+i]) * single([ 4+i ; 5+i ; 6+i]), single(29+21i), 5e-7) -%!assert(single([1+i 2+i ; 3+i 4+i ]) * single([5+i ; 6+i]), single([15 + 14i ; 37 + 18i]), 5e-7) -%!assert(single([1+i 2+i ; 3+i 4+i ]) * single([5+i 6+i ; 7+i 8+i]), single([17 + 15i 20 + 17i; 41 + 19i 48 + 21i]), 5e-7) -%!assert(single([1 i])*single([i 0])', single(-i)); -*/ - -/* Test some simple identities +/* + +## Simple Dot Product, Matrix-Vector, and Matrix-Matrix Unit tests +%!assert (single ([1+i 2+i 3+i]) * single ([ 4+i ; 5+i ; 6+i]), single (29+21i), 5e-7) +%!assert (single ([1+i 2+i ; 3+i 4+i]) * single ([5+i ; 6+i]), single ([15 + 14i ; 37 + 18i]), 5e-7) +%!assert (single ([1+i 2+i ; 3+i 4+i ]) * single ([5+i 6+i ; 7+i 8+i]), single ([17 + 15i 20 + 17i; 41 + 19i 48 + 21i]), 5e-7) +%!assert (single ([1 i])*single ([i 0])', single (-i)) + +## Test some simple identities %!shared M, cv, rv -%! M = single(randn(10,10))+i*single(rand(10,10)); -%! cv = single(randn(10,1))+i*single(rand(10,1)); -%! rv = single(randn(1,10))+i*single(rand(1,10)); -%!assert([M*cv,M*cv],M*[cv,cv],5e-6) -%!assert([M.'*cv,M.'*cv],M.'*[cv,cv],5e-6) -%!assert([M'*cv,M'*cv],M'*[cv,cv],5e-6) -%!assert([rv*M;rv*M],[rv;rv]*M,5e-6) -%!assert([rv*M.';rv*M.'],[rv;rv]*M.',5e-6) -%!assert([rv*M';rv*M'],[rv;rv]*M',5e-6) -%!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6) +%! M = single (randn (10,10))+ i*single (rand (10,10)); +%! cv = single (randn (10,1))+ i*single (rand (10,1)); +%! rv = single (randn (1,10))+ i*single (rand (1,10)); +%!assert ([M*cv,M*cv], M*[cv,cv], 5e-6) +%!assert ([M.'*cv,M.'*cv], M.'*[cv,cv], 5e-6) +%!assert ([M'*cv,M'*cv], M'*[cv,cv], 5e-6) +%!assert ([rv*M;rv*M], [rv;rv]*M, 5e-6) +%!assert ([rv*M.';rv*M.'], [rv;rv]*M.', 5e-6) +%!assert ([rv*M';rv*M'], [rv;rv]*M', 5e-6) +%!assert (2*rv*cv, [rv,rv]*[cv;cv], 5e-6) + */ static char
--- a/liboctave/fMatrix.cc +++ b/liboctave/fMatrix.cc @@ -3113,22 +3113,23 @@ // matrix by matrix -> matrix operations -/* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests -%!assert(single([1 2 3]) * single([ 4 ; 5 ; 6]), single(32), 5e-7) -%!assert(single([1 2 ; 3 4 ]) * single([5 ; 6]), single([17 ; 39 ]), 5e-7) -%!assert(single([1 2 ; 3 4 ]) * single([5 6 ; 7 8]), single([19 22; 43 50]), 5e-7) -*/ - -/* Test some simple identities +/* +## Simple Dot Product, Matrix-Vector, and Matrix-Matrix Unit tests +%!assert (single ([1 2 3]) * single ([ 4 ; 5 ; 6]), single (32), 5e-7) +%!assert (single ([1 2 ; 3 4]) * single ([5 ; 6]), single ([17 ; 39]), 5e-7) +%!assert (single ([1 2 ; 3 4]) * single ([5 6 ; 7 8]), single ([19 22; 43 50]), 5e-7) + +## Test some simple identities %!shared M, cv, rv -%! M = single(randn(10,10)); -%! cv = single(randn(10,1)); -%! rv = single(randn(1,10)); -%!assert([M*cv,M*cv],M*[cv,cv],5e-6) -%!assert([M'*cv,M'*cv],M'*[cv,cv],5e-6) -%!assert([rv*M;rv*M],[rv;rv]*M,5e-6) -%!assert([rv*M';rv*M'],[rv;rv]*M',5e-6) -%!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6) +%! M = single (randn (10,10)); +%! cv = single (randn (10,1)); +%! rv = single (randn (1,10)); +%!assert ([M*cv,M*cv], M*[cv,cv], 5e-6) +%!assert ([M'*cv,M'*cv], M'*[cv,cv], 5e-6) +%!assert ([rv*M;rv*M], [rv;rv]*M, 5e-6) +%!assert ([rv*M';rv*M'], [rv;rv]*M', 5e-6) +%!assert (2*rv*cv, [rv,rv]*[cv;cv], 5e-6) + */ static char
--- a/liboctave/oct-inttypes.cc +++ b/liboctave/oct-inttypes.cc @@ -630,24 +630,23 @@ INSTANTIATE_INTTYPE (uint64_t); -// Tests follow. - /* -%!assert(intmax("int64")/intmin("int64"),int64(-1)) -%!assert(intmin("int64")/int64(-1),intmax("int64")) -%!assert(int64(2**63),intmax("int64")) -%!assert(uint64(2**64),intmax("uint64")) +%!assert (intmax ("int64") / intmin ("int64"), int64 (-1)) +%!assert (intmin ("int64") / int64 (-1), intmax ("int64")) +%!assert (int64 (2**63), intmax ("int64")) +%!assert (uint64 (2**64), intmax ("uint64")) %!test -%! a = 1.9*2^61; b = uint64(a); b++; assert(b > a) +%! a = 1.9*2^61; b = uint64 (a); b++; assert (b > a); %!test -%! a = -1.9*2^61; b = int64(a); b++; assert(b > a) +%! a = -1.9*2^61; b = int64 (a); b++; assert (b > a); %!test -%! a = int64(-2**60) + 2; assert(1.25*a == (5*a)/4) +%! a = int64 (-2**60) + 2; assert (1.25*a == (5*a)/4); %!test -%! a = uint64(2**61) + 2; assert(1.25*a == (5*a)/4) -%!assert(int32(2**31+0.5),intmax('int32')) -%!assert(int32(-2**31-0.5),intmin('int32')) -%!assert((int64(2**62)+1)**1, int64(2**62)+1) -%!assert((int64(2**30)+1)**2, int64(2**60+2**31) + 1) +%! a = uint64 (2**61) + 2; assert (1.25*a == (5*a)/4); +%!assert (int32 (2**31+0.5), intmax ("int32")) +%!assert (int32 (-2**31-0.5), intmin ("int32")) +%!assert ((int64 (2**62)+1)**1, int64 (2**62)+1) +%!assert ((int64 (2**30)+1)**2, int64 (2**60+2**31) + 1) + */