85 |
|
|
86 |
cholmod_sdmult(cha, 0, &alpha, &beta, chb, chc, &c); |
cholmod_sdmult(cha, 0, &alpha, &beta, chb, chc, &c); |
87 |
Free(cha); Free(chb); |
Free(cha); Free(chb); |
88 |
return chm_sparse_to_SEXP(chc, 1); |
return chm_dense_to_SEXP(chc, 1); |
89 |
#else |
#else |
90 |
error("General multiplication requires CHOLMOD"); |
error("General multiplication requires CHOLMOD"); |
91 |
return R_NilValue; /* -Wall */ |
return R_NilValue; /* -Wall */ |
92 |
#endif /* USE_CHOLMOD */ |
#endif /* USE_CHOLMOD */ |
93 |
} |
} |
94 |
|
|
95 |
SEXP Csparse_tcrossprod(SEXP x) |
SEXP Csparse_crossprod(SEXP x, SEXP trans) |
96 |
{ |
{ |
97 |
#ifdef USE_CHOLMOD |
#ifdef USE_CHOLMOD |
98 |
cholmod_sparse *chx = as_cholmod_sparse(x); |
int tr = asLogical(trans); /* gets reversed because _aat is trcrossprod */ |
99 |
cholmod_sparse *chxt = cholmod_aat(chx, (int *) NULL, 0, chx->xtype, &c); |
cholmod_sparse *chx = as_cholmod_sparse(x), *chcp, *chxt; |
100 |
|
|
101 |
|
if (!tr) |
102 |
|
chxt = cholmod_transpose(chx, (int) chx->xtype, &c); |
103 |
|
chcp = cholmod_aat((tr) ? chxt : chx, (int *) NULL, 0, chx->xtype, &c); |
104 |
|
|
105 |
Free(chx); |
Free(chx); |
106 |
return chm_sparse_to_SEXP(chxt, 1); |
if (!tr) cholmod_free_sparse(&chxt, &c); |
107 |
|
return chm_sparse_to_SEXP(chcp, 1); |
108 |
#else |
#else |
109 |
error("General transpose requires CHOLMOD"); |
error("General transpose requires CHOLMOD"); |
110 |
return R_NilValue; /* -Wall */ |
return R_NilValue; /* -Wall */ |
111 |
#endif /* USE_CHOLMOD */ |
#endif /* USE_CHOLMOD */ |
112 |
} |
} |
113 |
|
|