4
|
1 function retval = cond (a) |
|
2 |
|
3 # usage: cond (a) |
|
4 # |
|
5 # Return the condition number of a, computed using the singular values |
|
6 # of a. |
|
7 # |
|
8 # See also: norm, svd |
|
9 |
|
10 if (nargin == 1) |
|
11 [nr, nc] = size (a); |
|
12 if (nr == 0 && nc == 0) |
|
13 if (strcmp (propagate_empty_matrices, "false")) |
|
14 error ("cond: empty matrix is invalid as argument"); |
|
15 endif |
|
16 if (strcmp (propagate_empty_matrices, "warn")) |
|
17 printf ("warning: cond: argument is empty matrix\n"); |
|
18 endif |
|
19 retval = 0.0; |
|
20 endif |
|
21 sigma = svd (a); |
|
22 retval = sigma (1) / sigma (length (sigma)); |
|
23 else |
|
24 error ("usage: cond (a)"); |
|
25 endif |
|
26 |
|
27 endfunction |