51 #define xSTRINGIZE(x) #x
52 #define STRINGIZE(x) xSTRINGIZE(x)
152 template<
class T1,
class T2>
185 template<
class T1,
class T2>
235 double *tmp_dataA,
F77_INT m1,
double *tmp_dataB,
247 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
248 F77_CONST_CHAR_ARG2 (&jobv, 1),
249 F77_CONST_CHAR_ARG2 (&jobq, 1),
250 m,
n, p, k, l, tmp_dataA, m1, tmp_dataB, p1,
252 u, nrow_u, v, nrow_v, q, nrow_q,
256 F77_CHAR_ARG_LEN (1));
261 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
262 F77_CONST_CHAR_ARG2 (&jobv, 1),
263 F77_CONST_CHAR_ARG2 (&jobq, 1),
264 m,
n, p, k, l, tmp_dataA, m1, tmp_dataB, p1,
266 u, nrow_u, v, nrow_v, q, nrow_q,
270 F77_CHAR_ARG_LEN (1));
278 float *tmp_dataA,
F77_INT m1,
float *tmp_dataB,
281 float *v,
F77_INT nrow_v,
float *q,
291 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
292 F77_CONST_CHAR_ARG2 (&jobv, 1),
293 F77_CONST_CHAR_ARG2 (&jobq, 1),
294 m,
n, p, k, l, tmp_dataA, m1, tmp_dataB, p1,
296 u, nrow_u, v, nrow_v, q, nrow_q,
300 F77_CHAR_ARG_LEN (1));
305 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
306 F77_CONST_CHAR_ARG2 (&jobv, 1),
307 F77_CONST_CHAR_ARG2 (&jobq, 1),
308 m,
n, p, k, l, tmp_dataA, m1, tmp_dataB, p1,
310 u, nrow_u, v, nrow_v, q, nrow_q,
314 F77_CHAR_ARG_LEN (1));
336 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
337 F77_CONST_CHAR_ARG2 (&jobv, 1),
338 F77_CONST_CHAR_ARG2 (&jobq, 1),
350 F77_CHAR_ARG_LEN (1));
355 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
356 F77_CONST_CHAR_ARG2 (&jobv, 1),
357 F77_CONST_CHAR_ARG2 (&jobq, 1),
369 F77_CHAR_ARG_LEN (1));
394 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
395 F77_CONST_CHAR_ARG2 (&jobv, 1),
396 F77_CONST_CHAR_ARG2 (&jobq, 1),
408 F77_CHAR_ARG_LEN (1));
413 f_ptr (F77_CONST_CHAR_ARG2 (&jobu, 1),
414 F77_CONST_CHAR_ARG2 (&jobv, 1),
415 F77_CONST_CHAR_ARG2 (&jobq, 1),
427 F77_CHAR_ARG_LEN (1));
431 template <
typename T>
437 (*current_liboctave_error_handler)
438 (
"gsvd: U not computed because type == gsvd::sigma_only");
445 template <
typename T>
451 (*current_liboctave_error_handler)
452 (
"gsvd: V not computed because type == gsvd::sigma_only");
459 template <
typename T>
465 (*current_liboctave_error_handler)
466 (
"gsvd: X not computed because type == gsvd::sigma_only");
473 template <
typename T>
479 (*current_liboctave_error_handler)
480 (
"gsvd: R not computed because type != gsvd::std");
487 template <
typename T>
494 F77_INT p = to_f77_int (b.rows ());
497 P *tmp_dataA = atmp.fortran_vec ();
500 P *tmp_dataB = btmp.fortran_vec ();
527 nrow_u = nrow_v = nrow_q = 1;
536 if (! (jobu ==
'N' || jobu ==
'O'))
537 left_smA.resize (nrow_u,
m);
539 P *u = left_smA.fortran_vec ();
541 if (! (jobv ==
'N' || jobv ==
'O'))
542 left_smB.resize (nrow_v, p);
544 P *v = left_smB.fortran_vec ();
546 if (! (jobq ==
'N' || jobq ==
'O'))
547 right_sm.resize (nrow_q,
n);
549 P *q = right_sm.fortran_vec ();
554 std::vector<F77_INT> iwork (
n);
566 tmp_dataA,
m, tmp_dataB, p, alpha, beta, u,
567 nrow_u, v, nrow_v, q, nrow_q, work_tmp, lwork,
568 iwork.data (), info);
575 lwork = (lwork >
m ? lwork :
m);
576 lwork = (lwork > p ? lwork : p) +
n;
583 tmp_dataA,
m, tmp_dataB, p, alpha, beta, u,
584 nrow_u, v, nrow_v, q, nrow_q, work, lwork, iwork.data (),
588 (*current_liboctave_error_handler) (
"*ggsvd.f: argument %d illegal",
593 (*current_liboctave_error_handler)
594 (
"*ggsvd.f: Jacobi-type procedure failed to converge.");
607 for (i = 0; i < k+l; i++)
608 for (j = 0; j < k+l; j++)
609 R.xelem (i, j) = atmp.xelem (i, astart + j);
616 for (i = 0; i <
m; i++)
617 for (j = 0; j < k+l; j++)
618 R.xelem (i, j) = atmp.xelem (i, astart + j);
620 for (i = k+l-1; i >=
m; i--)
622 for (j = 0; j <
m; j++)
624 for (j =
m; j < k+l; j++)
625 R.xelem (i, j) = btmp.xelem (i - k, astart + j);
633 sigmaA.resize (l, l);
634 sigmaB.resize (l, l);
635 for (i = 0; i < l; i++)
637 sigmaA.dgxelem(i) = alpha.elem(k+i);
638 sigmaB.dgxelem(i) = beta.elem(k+i);
644 sigmaA.resize (
m-k,
m-k);
645 sigmaB.resize (
m-k,
m-k);
646 for (i = 0; i <
m-k; i++)
648 sigmaA.dgxelem(i) = alpha.elem(k+i);
649 sigmaB.dgxelem(i) = beta.elem(k+i);
const T * fortran_vec(void) const
Size of the specified dimension.
void * search(const std::string &nm, const name_mangler &mangler=name_mangler()) const
void ggsvd(char &jobu, char &jobv, char &jobq, octave_f77_int_type m, octave_f77_int_type n, octave_f77_int_type p, octave_f77_int_type &k, octave_f77_int_type &l, P *tmp_dataA, octave_f77_int_type m1, P *tmp_dataB, octave_f77_int_type p1, real_matrix &alpha, real_matrix &beta, P *u, octave_f77_int_type nrow_u, P *v, octave_f77_int_type nrow_v, P *q, octave_f77_int_type nrow_q, T &work, octave_f77_int_type lwork, octave_f77_int_type *iwork, octave_f77_int_type &info)
T::real_matrix_type real_matrix
T right_singular_matrix(void) const
T left_singular_matrix_A(void) const
T left_singular_matrix_B(void) const
#define F77_DBLE_CMPLX_ARG(x)
octave_f77_int_type F77_INT
static octave::math::gsvd< T >::Type gsvd_type(int nargout)
F77_RET_T F77_CONST_CHAR_ARG_DECL
F77_RET_T const F77_INT F77_INT const F77_DBLE F77_DBLE const F77_INT F77_DBLE const F77_INT F77_INT F77_INT F77_DBLE F77_DBLE const F77_INT F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL
F77_RET_T(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_DBLE *, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
static void initialize_gsvd(void)
static bool gsvd_initialized
static std::map< std::string, void * > gsvd_fcn
comp_ggsvd_ptr< F77_DBLE_CMPLX, F77_DBLE >::type zggsvd_type
real_ggsvd_ptr< F77_REAL >::type sggsvd_type
comp_ggsvd3_ptr< F77_DBLE_CMPLX, F77_DBLE >::type zggsvd3_type
real_ggsvd3_ptr< F77_DBLE >::type dggsvd3_type
comp_ggsvd_ptr< F77_CMPLX, F77_REAL >::type cggsvd_type
real_ggsvd_ptr< F77_DBLE >::type dggsvd_type
comp_ggsvd3_ptr< F77_CMPLX, F77_REAL >::type cggsvd3_type
real_ggsvd3_ptr< F77_REAL >::type sggsvd3_type
std::complex< double > Complex
std::complex< float > FloatComplex
F77_RET_T(* type)(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T2 *, T2 *, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T2 *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
F77_RET_T(* type)(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T2 *, T2 *, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, T2 *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
F77_RET_T(* type)(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, T1 *, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
F77_RET_T(* type)(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, T1 *, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, const F77_INT &, T1 *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg