26 #if defined (HAVE_CONFIG_H)
53 (*current_liboctave_error_handler)
54 (
"svd: U not computed because type == svd::sigma_only");
64 (*current_liboctave_error_handler)
65 (
"svd: V not computed because type == svd::sigma_only");
72 #define GESVD_REAL_STEP(f, F) \
73 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobu, 1), \
74 F77_CONST_CHAR_ARG2 (&jobv, 1), \
75 m, n, tmp_data, m1, s_vec, u, m1, vt, \
76 nrow_vt1, work.data (), lwork, info \
77 F77_CHAR_ARG_LEN (1) \
78 F77_CHAR_ARG_LEN (1)))
80 #define GESVD_COMPLEX_STEP(f, F, CMPLX_ARG) \
81 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobu, 1), \
82 F77_CONST_CHAR_ARG2 (&jobv, 1), \
83 m, n, CMPLX_ARG (tmp_data), \
84 m1, s_vec, CMPLX_ARG (u), m1, \
85 CMPLX_ARG (vt), nrow_vt1, \
86 CMPLX_ARG (work.data ()), \
87 lwork, rwork.data (), info \
88 F77_CHAR_ARG_LEN (1) \
89 F77_CHAR_ARG_LEN (1)))
95 double *tmp_data,
F77_INT m1,
double *s_vec,
96 double *u,
double *vt,
F77_INT nrow_vt1,
97 std::vector<double>& work,
F77_INT& lwork,
102 lwork =
static_cast<F77_INT> (work[0]);
103 work.reserve (lwork);
112 float *tmp_data,
F77_INT m1,
float *s_vec,
113 float *u,
float *vt,
F77_INT nrow_vt1,
114 std::vector<float>& work,
F77_INT& lwork,
119 lwork =
static_cast<F77_INT> (work[0]);
120 work.reserve (lwork);
131 std::vector<Complex>& work,
F77_INT& lwork,
134 std::vector<double> rwork (5 *
std::max (
m,
n));
138 lwork =
static_cast<F77_INT> (work[0].real ());
139 work.reserve (lwork);
151 std::vector<FloatComplex>& work,
154 std::vector<float> rwork (5 *
std::max (
m,
n));
158 lwork =
static_cast<F77_INT> (work[0].real ());
159 work.reserve (lwork);
164 #undef GESVD_REAL_STEP
165 #undef GESVD_COMPLEX_STEP
169 #define GESDD_REAL_STEP(f, F) \
170 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobz, 1), \
171 m, n, tmp_data, m1, s_vec, u, m1, vt, nrow_vt1, \
172 work.data (), lwork, iwork, info \
173 F77_CHAR_ARG_LEN (1)))
175 #define GESDD_COMPLEX_STEP(f, F, CMPLX_ARG) \
176 F77_XFCN (f, F, (F77_CONST_CHAR_ARG2 (&jobz, 1), m, n, \
177 CMPLX_ARG (tmp_data), m1, \
178 s_vec, CMPLX_ARG (u), m1, \
179 CMPLX_ARG (vt), nrow_vt1, \
180 CMPLX_ARG (work.data ()), lwork, \
181 rwork.data (), iwork, info \
182 F77_CHAR_ARG_LEN (1)))
188 F77_INT m1,
double *s_vec,
double *u,
double *vt,
189 F77_INT nrow_vt1, std::vector<double>& work,
194 lwork =
static_cast<F77_INT> (work[0]);
195 work.reserve (lwork);
204 F77_INT m1,
float *s_vec,
float *u,
float *vt,
205 F77_INT nrow_vt1, std::vector<float>& work,
210 lwork =
static_cast<F77_INT> (work[0]);
211 work.reserve (lwork);
222 std::vector<Complex>& work,
F77_INT& lwork,
233 lrwork = min_mn *
std::max (5*min_mn+5, 2*max_mn+2*min_mn+1);
235 std::vector<double> rwork (lrwork);
239 lwork =
static_cast<F77_INT> (work[0].real ());
240 work.reserve (lwork);
252 std::vector<FloatComplex>& work,
263 lrwork = min_mn *
std::max (5*min_mn+5, 2*max_mn+2*min_mn+1);
264 std::vector<float> rwork (lrwork);
268 lwork =
static_cast<F77_INT> (work[0].real ());
269 work.reserve (lwork);
274 #undef GESDD_REAL_STEP
275 #undef GESDD_COMPLEX_STEP
280 : m_type (
type), m_driver (driver), left_sm (), sigma (), right_sm ()
287 if (
m == 0 ||
n == 0)
316 P *tmp_data = atmp.fortran_vec ();
332 ncol_u = nrow_vt = nrow_s = ncol_s = min_mn;
345 ncol_u = nrow_vt = 1;
352 if (! (jobu ==
'N' || jobu ==
'O'))
357 sigma.resize (nrow_s, ncol_s);
360 if (! (jobv ==
'N' || jobv ==
'O'))
369 std::vector<P> work (1);
375 gesvd (jobu, jobv,
m,
n, tmp_data, m1, s_vec, u, vt, nrow_vt1,
379 assert (jobu == jobv);
382 std::vector<F77_INT> iwork (8 *
std::min (
m,
n));
384 gesdd (jobz,
m,
n, tmp_data, m1, s_vec, u, vt, nrow_vt1,
385 work, lwork, iwork.data (), info);
393 if (!
sigma.dgxelem (i))
397 if (! (jobv ==
'N' || jobv ==
'O'))
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
void gesdd(char &jobz, octave_f77_int_type m, octave_f77_int_type n, P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u, P *vt, octave_f77_int_type nrow_vt1, std::vector< P > &work, octave_f77_int_type &lwork, octave_f77_int_type *iwork, octave_f77_int_type &info)
T::real_diag_matrix_type DM_T
T right_singular_matrix(void) const
T left_singular_matrix(void) const
void gesvd(char &jobu, char &jobv, octave_f77_int_type m, octave_f77_int_type n, P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u, P *vt, octave_f77_int_type nrow_vt1, std::vector< P > &work, octave_f77_int_type &lwork, octave_f77_int_type &info)
#define F77_DBLE_CMPLX_ARG(x)
octave_f77_int_type F77_INT
#define GESVD_REAL_STEP(f, F)
#define GESDD_COMPLEX_STEP(f, F, CMPLX_ARG)
#define GESDD_REAL_STEP(f, F)
#define GESVD_COMPLEX_STEP(f, F, CMPLX_ARG)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
std::complex< double > Complex
std::complex< float > FloatComplex