[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug+patch: norm(X, "fro") fails when X has zero norm
From: |
jfc |
Subject: |
Bug+patch: norm(X, "fro") fails when X has zero norm |
Date: |
Sun, 30 Dec 2007 11:35:38 -0800 (PST) |
Hello all,
here is a simple patch for a bug introduced around 2.9.16
Bug: norm(zeros(3), "fro") returns "NaN" and raises a warning.
The obvious patch to __norm__.m and Changelog is attached.
Congrats on 3.0 !
Cheers, JF
*** scripts/linear-algebra/__norm__.m Wed Nov 7 18:38:29 2007
--- scripts/linear-algebra/__norm__fixed.m Sun Dec 30 20:01:35 2007
***************
*** 70,76 ****
if (ischar (p))
if (strcmp (p, "fro"))
inf_norm = norm (x, "inf");
! retval = inf_norm .* sqrt (sum (sum (abs (x ./ inf_norm) .^ 2)));
elseif (strcmp (p, "inf"))
retval = max (sum (abs (x')));
else
--- 70,80 ----
if (ischar (p))
if (strcmp (p, "fro"))
inf_norm = norm (x, "inf");
! if (inf_norm==0)
! retval = 0 ;
! else
! retval = inf_norm .* sqrt (sum (sum (abs (x ./ inf_norm) .^ 2)));
! endif
elseif (strcmp (p, "inf"))
retval = max (sum (abs (x')));
else
*** scripts/ChangeLog.~1.1124.~ Sun Dec 30 19:54:46 2007
--- scripts/ChangeLog Sun Dec 30 20:16:53 2007
***************
*** 1,3 ****
--- 1,8 ----
+ 2007-12-31 Jean-Francois Cardoso <address@hidden>
+
+ * linear-algebra/__norm__.m: norm(X, "fro") now works even if X is
+ a zero matrix.
+
2007-12-28 John W. Eaton <address@hidden>
* miscellaneous/edit.m: Use strcat instead of fullfile to add file
--
View this message in context:
http://www.nabble.com/Bug%2Bpatch%3A--norm%28X%2C-%22fro%22%29-fails-when-X-has-zero-norm-tp14550359p14550359.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bug+patch: norm(X, "fro") fails when X has zero norm,
jfc <=