comparison scripts/linear-algebra/null.m @ 557:e6ae50d8d4eb

[project @ 1994-07-25 20:23:22 by jwe] Initial revision
author jwe
date Mon, 25 Jul 1994 20:23:22 +0000
parents
children 4fcd2e68dd3b
comparison
equal deleted inserted replaced
556:b805b12f3b66 557:e6ae50d8d4eb
1 function retval = null (A, tol)
2
3 # usage: null (A, tol)
4 # null (A)
5 #
6 # Returns an orthonormal basis of the null space of A.
7 #
8 # The dimension of the null space is taken as the number of singular
9 # values of A not greater than tol; the default for tol is
10 # max (size (A)) * sigma_max (A) * eps, where sigma_max (A) is the
11 # maximal singular value of A.
12
13 # written by KH (Kurt.Hornik@neuro.tuwien.ac.at) on Dec 24, 1993
14 # copyright Dept of Probability Theory and Statistics TU Wien
15
16 [U, S, V] = svd (A);
17
18 [rows, cols] = size (A);
19
20 s = diag (S);
21
22 if (nargin == 1)
23 tol = max (size (A)) * s (1) * eps;
24 else (nargin != 2)
25 error("usage: null(A [, tol])");
26 endif
27
28 rank = sum (s > tol);
29
30 if (rank < cols)
31 retval = V (:, rank+1:cols);
32 else
33 retval = zeros (cols, 0);
34 endif
35
36 endfunction