26 #if defined (HAVE_CONFIG_H)
45 static typename math::
svd<T>::Type
48 if (nargout == 0 || nargout == 1)
49 return math::svd<T>::Type::sigma_only;
51 return math::svd<T>::Type::std;
52 else if (! args(1).is_real_scalar ())
53 return math::svd<T>::Type::economy;
56 if (
A.rows () >
A.columns ())
57 return math::svd<T>::Type::economy;
59 return math::svd<T>::Type::std;
64 static typename math::svd<T>::Driver
68 return math::svd<T>::Driver::GEJSV;
70 return math::svd<T>::Driver::GESDD;
72 return math::svd<T>::Driver::GESVD;
76 classes:
double single
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 ());
439 static const char *driver_names[] = {
"gesvd",
"gesdd",
"gejsv",
nullptr };
442 "svd_driver", driver_names);
OCTAVE_API bool any_element_is_inf_or_nan(void) const
ColumnVector extract_diag(octave_idx_type k=0) const
OCTAVE_API bool any_element_is_inf_or_nan(void) const
FloatColumnVector extract_diag(octave_idx_type k=0) const
OCTAVE_API bool any_element_is_inf_or_nan(void) const
OCTAVE_API bool any_element_is_inf_or_nan(void) const
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
FloatMatrix float_matrix_value(bool frc_str_conv=false) const
bool is_single_type(void) const
Matrix matrix_value(bool frc_str_conv=false) const
FloatComplexMatrix float_complex_matrix_value(bool frc_str_conv=false) const
bool iscomplex(void) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
void err_wrong_type_arg(const char *name, const char *s)
static std::string Vsvd_driver
static math::svd< T >::Type svd_type(int nargin, int nargout, const octave_value_list &args, const T &A)
static math::svd< T >::Driver svd_driver(void)
F77_RET_T const F77_INT F77_CMPLX * A
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)