178 int nargin = args.
length ();
180 if (nargin < 1 || nargin > 2 || nargout > 3)
185 if (arg.
ndims () != 2)
186 error (
"svd: A must be a 2-D matrix");
199 error (
"svd: cannot take SVD of matrix containing Inf or NaN values");
201 math::svd<FloatMatrix> result
203 svd_type<FloatMatrix> (nargin, nargout, args, tmp),
204 svd_driver<FloatMatrix> ());
208 if (nargout == 0 || nargout == 1)
210 else if (nargout == 2)
211 retval =
ovl (result.left_singular_matrix (),
214 retval =
ovl (result.left_singular_matrix (),
216 result.right_singular_matrix ());
223 error (
"svd: cannot take SVD of matrix containing Inf or NaN values");
225 math::svd<FloatComplexMatrix> result
227 svd_type<FloatComplexMatrix> (nargin, nargout, args, ctmp),
228 svd_driver<FloatComplexMatrix> ());
232 if (nargout == 0 || nargout == 1)
234 else if (nargout == 2)
235 retval =
ovl (result.left_singular_matrix (),
238 retval =
ovl (result.left_singular_matrix (),
240 result.right_singular_matrix ());
250 error (
"svd: cannot take SVD of matrix containing Inf or NaN values");
252 math::svd<Matrix> result
254 svd_type<Matrix> (nargin, nargout, args, tmp),
255 svd_driver<Matrix> ());
259 if (nargout == 0 || nargout == 1)
261 else if (nargout == 2)
262 retval =
ovl (result.left_singular_matrix (),
265 retval =
ovl (result.left_singular_matrix (),
267 result.right_singular_matrix ());
274 error (
"svd: cannot take SVD of matrix containing Inf or NaN values");
276 math::svd<ComplexMatrix> result
278 svd_type<ComplexMatrix> (nargin, nargout, args, ctmp),
279 svd_driver<ComplexMatrix> ());
283 if (nargout == 0 || nargout == 1)
285 else if (nargout == 2)
286 retval =
ovl (result.left_singular_matrix (),
289 retval =
ovl (result.left_singular_matrix (),
291 result.right_singular_matrix ());
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.