Mercurial > octave
comparison src/svd.cc @ 1310:f62e82e0a2ce
[project @ 1995-06-25 04:08:32 by jwe]
author | jwe |
---|---|
date | Sun, 25 Jun 1995 04:08:32 +0000 |
parents | b6360f2d4fa6 |
children | 611d403c7f3d |
comparison
equal
deleted
inserted
replaced
1309:c0187e1c02f9 | 1310:f62e82e0a2ce |
---|---|
28 #include "dbleSVD.h" | 28 #include "dbleSVD.h" |
29 #include "CmplxSVD.h" | 29 #include "CmplxSVD.h" |
30 | 30 |
31 #include "tree-const.h" | 31 #include "tree-const.h" |
32 #include "user-prefs.h" | 32 #include "user-prefs.h" |
33 #include "pr-output.h" | |
34 #include "mappers.h" | |
33 #include "gripes.h" | 35 #include "gripes.h" |
34 #include "error.h" | 36 #include "error.h" |
35 #include "utils.h" | 37 #include "utils.h" |
36 #include "help.h" | 38 #include "help.h" |
37 #include "defun-dld.h" | 39 #include "defun-dld.h" |
39 DEFUN_DLD_BUILTIN ("svd", Fsvd, Ssvd, 2, 3, | 41 DEFUN_DLD_BUILTIN ("svd", Fsvd, Ssvd, 2, 3, |
40 "S = svd (X) or [U, S, V] = svd (X [, 0])\n\ | 42 "S = svd (X) or [U, S, V] = svd (X [, 0])\n\ |
41 \n\ | 43 \n\ |
42 Compute the singular value decomposition of X. Given a second input\n\ | 44 Compute the singular value decomposition of X. Given a second input\n\ |
43 argument, an `economy' sized factorization is computed that omits\n\ | 45 argument, an `economy' sized factorization is computed that omits\n\ |
44 unnecessary rows and columns of U and V") | 46 unnecessary rows and columns of U and V.\n\ |
47 \n\ | |
48 X may not contain any Inf or NaN values.") | |
45 { | 49 { |
46 Octave_object retval; | 50 Octave_object retval; |
47 | 51 |
48 int nargin = args.length (); | 52 int nargin = args.length (); |
49 | 53 |
68 { | 72 { |
69 Matrix tmp = arg.matrix_value (); | 73 Matrix tmp = arg.matrix_value (); |
70 | 74 |
71 if (! error_state) | 75 if (! error_state) |
72 { | 76 { |
77 if (any_element_is_inf_or_nan (tmp)) | |
78 { | |
79 error ("svd: cannot take SVD of matrix containing Inf or\ | |
80 NaN values"); | |
81 return retval; | |
82 } | |
83 | |
73 SVD result (tmp, type); | 84 SVD result (tmp, type); |
74 | 85 |
75 DiagMatrix sigma = result.singular_values (); | 86 DiagMatrix sigma = result.singular_values (); |
76 | 87 |
77 if (nargout == 0 || nargout == 1) | 88 if (nargout == 0 || nargout == 1) |
90 { | 101 { |
91 ComplexMatrix ctmp = arg.complex_matrix_value (); | 102 ComplexMatrix ctmp = arg.complex_matrix_value (); |
92 | 103 |
93 if (! error_state) | 104 if (! error_state) |
94 { | 105 { |
106 if (any_element_is_inf_or_nan (ctmp)) | |
107 { | |
108 error ("svd: cannot take SVD of matrix containing Inf or\ | |
109 NaN values"); | |
110 return retval; | |
111 } | |
112 | |
95 ComplexSVD result (ctmp, type); | 113 ComplexSVD result (ctmp, type); |
96 | 114 |
97 DiagMatrix sigma = result.singular_values (); | 115 DiagMatrix sigma = result.singular_values (); |
98 | 116 |
99 if (nargout == 0 || nargout == 1) | 117 if (nargout == 0 || nargout == 1) |