changeset 12829:ab529124f516

codesprint: Wrote 3 tests for sqrtm.cc
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Sat, 16 Jul 2011 16:12:09 -0500
parents 0bf51abcf759
children 208f0a181be6
files src/DLD-FUNCTIONS/sqrtm.cc
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/sqrtm.cc
+++ b/src/DLD-FUNCTIONS/sqrtm.cc
@@ -270,3 +270,20 @@
 
   return retval;
 }
+
+/*
+
+%!assert (sqrtm (2*ones (2)), ones (2), 3*eps)
+
+## The following two tests are from the reference in the docstring above.
+
+%!assert (isnan (sqrtm ([0 1; 0 0])))
+
+%!test
+%! x = eye (4); x(2,2) = x(3,3) = 2^-26; x(1,4) = 1;
+%! z = eye (4); z(2,2) = z(3,3) = 2^-13; z(1,4) = 0.5;
+%! [y, err] = sqrtm(x);
+%! assert (y, z)
+%! assert (err, 0)## Yes, this one has to hold exactly
+
+*/