diff scripts/linear-algebra/null.m @ 4371:c14ec945fabb

[project @ 2003-03-26 16:05:59 by jwe]
author jwe
date Wed, 26 Mar 2003 16:05:59 +0000
parents 434790acb067
children 4c8a2e4e0717
line wrap: on
line diff
--- a/scripts/linear-algebra/null.m	Tue Mar 18 10:34:13 2003 +0000
+++ b/scripts/linear-algebra/null.m	Wed Mar 26 16:05:59 2003 +0000
@@ -36,30 +36,34 @@
 
 function retval = null (A, tol)
 
-  [U, S, V] = svd (A);
-
-  [rows, cols] = size (A);
-
-  [S_nr, S_nc] = size (S);
+  if (isempty (A))
+    retval = [];
+  else
+    [U, S, V] = svd (A);
 
-  if (S_nr == 1 || S_nc == 1)
-    s = S(1);
-  else
-    s = diag (S);
-  endif
+    [rows, cols] = size (A);
+
+    [S_nr, S_nc] = size (S);
 
-  if (nargin == 1)
-    tol = max (size (A)) * s (1) * eps;
-  elseif (nargin != 2)
-    usage ("null (A, tol)");
-  endif
+    if (S_nr == 1 || S_nc == 1)
+      s = S(1);
+    else
+      s = diag (S);
+    endif
 
-  rank = sum (s > tol);
+    if (nargin == 1)
+      tol = max (size (A)) * s (1) * eps;
+    elseif (nargin != 2)
+      usage ("null (A, tol)");
+    endif
 
-  if (rank < cols)
-    retval = V (:, rank+1:cols);
-  else
-    retval = zeros (cols, 0);
+    rank = sum (s > tol);
+
+    if (rank < cols)
+      retval = V (:, rank+1:cols);
+    else
+      retval = zeros (cols, 0);
+    endif
   endif
 
 endfunction