diff scripts/linear-algebra/cond.m @ 4:b4df021f796c

[project @ 1993-08-08 01:26:08 by jwe] Initial revision
author jwe
date Sun, 08 Aug 1993 01:26:08 +0000
parents
children 16a24e76d6e0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/linear-algebra/cond.m	Sun Aug 08 01:26:08 1993 +0000
@@ -0,0 +1,27 @@
+function retval = cond (a)
+
+# usage: cond (a)
+#
+# Return the condition number of a, computed using the singular values
+# of a.
+#
+# See also: norm, svd
+
+  if (nargin == 1)
+    [nr, nc] = size (a);
+    if (nr == 0 && nc == 0)
+      if (strcmp (propagate_empty_matrices, "false"))
+        error ("cond: empty matrix is invalid as argument");
+      endif
+      if (strcmp (propagate_empty_matrices, "warn"))
+        printf ("warning: cond: argument is empty matrix\n");
+      endif
+      retval = 0.0;
+    endif
+    sigma = svd (a);
+    retval = sigma (1) / sigma (length (sigma));
+  else
+    error ("usage: cond (a)");
+  endif
+
+endfunction