Mercurial > hg > octave-terminal
changeset 12806:a85ddaf8f402
codesprint: Wrote 8 tests for null.m
author | Sean Young <seannz@gmail.com> |
---|---|
date | Sat, 16 Jul 2011 13:21:59 -0500 |
parents | 3641167e5b75 |
children | 7b90b81a5793 |
files | scripts/linear-algebra/null.m |
diffstat | 1 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/linear-algebra/null.m +++ b/scripts/linear-algebra/null.m @@ -77,3 +77,35 @@ endif endfunction + +%!test +%! A = 0; +%! assert(null(A), 1); + +%!test +%! A = 1; +%! assert(null(A), zeros(1,0)) + +%!test +%! A = [1 0; 0 1]; +%! assert(null(A), zeros(2,0)); + +%!test +%! A = [1 0; 1 0]; +%! assert(null(A), [0 1]') + +%!test +%! A = [1 1; 0 0]; +%! assert(null(A), [-1/sqrt(2) 1/sqrt(2)]') + +%!test +%! tol = 1e-4; +%! A = [1 0; 0 tol-eps]; +%! assert(null(A,tol), [0 1]') + +%!test +%! tol = 1e-4; +%! A = [1 0; 0 tol+eps]; +%! assert(null(A,tol), zeros(2,0)); + +%!error null()