Mercurial > hg > octave-nkf
changeset 7382:4ec8f8a4f005
[project @ 2008-01-15 19:24:21 by jwe]
author | jwe |
---|---|
date | Tue, 15 Jan 2008 19:24:21 +0000 |
parents | 90b931a40617 |
children | 1ea9ee491098 |
files | scripts/ChangeLog scripts/linear-algebra/__norm__.m |
diffstat | 2 files changed, 24 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2008-01-15 John W. Eaton <jwe@octave.org> + + * linear-algebra/__norm__.m: Use sum(abs(x),2), not sum(abs(x.')). + 2008-01-15 Michael Goffioul <michael.goffioul@gmail.com> * plot/drawnow.m, plot/__go_draw_figure__.m, plot/__go_draw_axes__.m:
--- a/scripts/linear-algebra/__norm__.m +++ b/scripts/linear-algebra/__norm__.m @@ -80,7 +80,7 @@ retval = inf_norm; endif elseif (strcmp (p, "inf")) - retval = max (sum (abs (x.'))); + retval = max (sum (abs (x), 2)); else error ("norm: unrecognized vector norm"); endif @@ -91,7 +91,7 @@ s = svd (x); retval = s (1); elseif (p == Inf) - retval = max (sum (abs (x.'))); + retval = max (sum (abs (x), 2)); else error ("norm: unrecognized matrix norm"); endif @@ -101,23 +101,25 @@ endfunction %!test -%! x = __norm__ (zeros (5), "fro"); -%! assert (x, 0); -%! x = __norm__ (ones (5), "fro"); -%! assert (x, 5); -%! x = __norm__ (zeros (5,1), "fro"); -%! assert (x, 0); -%! x = __norm__ (2*ones (5,3), "fro"); -%! assert (x, sqrt (60)); +%! assert (__norm__ (magic (3)), 15, -2*eps); +%! assert (__norm__ (magic (3) * i), 15, -2*eps); + +%!test +%! assert (__norm__ (zeros (5), "fro"), 0); +%! assert (__norm__ (ones (5), "fro"), 5); +%! assert (__norm__ (zeros (5,1), "fro"), 0); +%! assert (__norm__ (2*ones (5,3), "fro"), sqrt (60)); %!test -%! x = __norm__ (zeros (5), "inf"); -%! assert (x, 0); -%! x = __norm__ (ones (5), "inf"); -%! assert (x, 5); -%! x = __norm__ (2*ones (5,1), "inf"); -%! assert (x, 0); -%! x = __norm__ (2*ones (5,3), "inf"); -%! assert (x, 6); +%! assert (__norm__ (zeros (5), "inf"), 0); +%! assert (__norm__ (ones (5), "inf"), 5); +%! assert (__norm__ (2*ones (5,1), "inf"), 2); +%! assert (__norm__ (2*ones (5,3), "inf"), 6); + +%!test +%! assert (__norm__ (zeros (5), 1), 0); +%! assert (__norm__ (ones (5), 1), 5); +%! assert (__norm__ (2*ones (1,5), 1), 10); +%! assert (__norm__ (2*ones (3,5), 1), 6);