13 int *pdim =
DIM(obj), n = pdim[1];
15 Rf_error(
_(
"matrix is not square"));
16 ul = (
class[1] !=
'g') ?
UPLO(obj) : (ul ==
'\0') ?
'U' : ul;
17 ct = (
class[1] ==
's' &&
class[0] ==
'z') ?
TRANS(obj) : ct;
18 char cl[] =
".denseBunchKaufman";
19 cl[0] = (
class[0] ==
'z') ?
'z' :
'd';
25 if (ct !=
'C' &&
class[0] ==
'z')
29 PROTECT_WITH_INDEX(obj, &pid);
30 if (
class[0] !=
'z' &&
class[0] !=
'd') {
34 if (
class[1] ==
't' &&
DIAG(obj) !=
'N')
36 SEXP perm = PROTECT(Rf_allocVector(INTSXP, n)),
38 y = PROTECT(Rf_allocVector(
TYPEOF(x), XLENGTH(x)));
39 int *pperm = INTEGER(perm), info;
40 if (
class[2] !=
'p') {
42 if (
TYPEOF(x) == CPLXSXP) {
43 Rcomplex *px = COMPLEX(x), *py = COMPLEX(y), tmp, *work;
44 memset(py, 0,
sizeof(Rcomplex) * (
size_t) XLENGTH(y));
45 F77_CALL(zlacpy)(&ul, &n, &n, px, &n, py, &n
FCONE);
47 F77_CALL(zhetrf)(&ul, &n, py, &n, pperm, &tmp, &lwork, &info
FCONE);
49 work = (Rcomplex *) R_alloc((
size_t) lwork,
sizeof(Rcomplex));
50 F77_CALL(zhetrf)(&ul, &n, py, &n, pperm, work, &lwork, &info
FCONE);
53 F77_CALL(zsytrf)(&ul, &n, py, &n, pperm, &tmp, &lwork, &info
FCONE);
55 work = (Rcomplex *) R_alloc((
size_t) lwork,
sizeof(Rcomplex));
56 F77_CALL(zsytrf)(&ul, &n, py, &n, pperm, work, &lwork, &info
FCONE);
60 double *px = REAL(x), *py = REAL(y), tmp, *work;
61 memset(py, 0,
sizeof(
double) * (
size_t) XLENGTH(y));
62 F77_CALL(dlacpy)(&ul, &n, &n, px, &n, py, &n
FCONE);
63 F77_CALL(dsytrf)(&ul, &n, py, &n, pperm, &tmp, &lwork, &info
FCONE);
65 work = (
double *) R_alloc((
size_t) lwork,
sizeof(
double));
66 F77_CALL(dsytrf)(&ul, &n, py, &n, pperm, work, &lwork, &info
FCONE);
70 if (
TYPEOF(x) == CPLXSXP) {
71 Rcomplex *px = COMPLEX(x), *py = COMPLEX(y);
72 memcpy(py, px,
sizeof(Rcomplex) * (
size_t) XLENGTH(y));
74 F77_CALL(zhptrf)(&ul, &n, py, pperm, &info
FCONE);
77 F77_CALL(zsptrf)(&ul, &n, py, pperm, &info
FCONE);
81 double *px = REAL(x), *py = REAL(y);
82 memcpy(py, px,
sizeof(
double) * (
size_t) XLENGTH(y));
83 F77_CALL(dsptrf)(&ul, &n, py, pperm, &info
FCONE);