64 |
duplicate(GET_SLOT(x, Matrix_DimNamesSym))); |
duplicate(GET_SLOT(x, Matrix_DimNamesSym))); |
65 |
} |
} |
66 |
|
|
67 |
SEXP Csparse_transpose(SEXP x) |
SEXP Csparse_transpose(SEXP x, SEXP tri) |
68 |
{ |
{ |
69 |
cholmod_sparse *chx = as_cholmod_sparse(x); |
cholmod_sparse *chx = as_cholmod_sparse(x); |
70 |
cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c); |
cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c); |
71 |
SEXP dn = PROTECT(duplicate(GET_SLOT(x, Matrix_DimNamesSym))), tmp; |
SEXP dn = PROTECT(duplicate(GET_SLOT(x, Matrix_DimNamesSym))), tmp; |
72 |
|
int uploT = 0; char *diag = ""; |
73 |
|
|
74 |
Free(chx); |
Free(chx); |
75 |
tmp = VECTOR_ELT(dn, 0); /* swap the dimnames */ |
tmp = VECTOR_ELT(dn, 0); /* swap the dimnames */ |
76 |
SET_VECTOR_ELT(dn, 0, VECTOR_ELT(dn, 1)); |
SET_VECTOR_ELT(dn, 0, VECTOR_ELT(dn, 1)); |
77 |
SET_VECTOR_ELT(dn, 1, tmp); |
SET_VECTOR_ELT(dn, 1, tmp); |
78 |
UNPROTECT(1); |
UNPROTECT(1); |
79 |
return chm_sparse_to_SEXP(chxt, 1, 0, "", dn); |
if (asLogical(tri)) { /* triangular sparse matrices */ |
80 |
|
uploT = (strcmp(CHAR(asChar(GET_SLOT(x, Matrix_uploSym))), "U")) ? |
81 |
|
1 : -1; /* switch upper and lower for transpose */ |
82 |
|
diag = CHAR(asChar(GET_SLOT(x, Matrix_diagSym))); |
83 |
|
} |
84 |
|
return chm_sparse_to_SEXP(chxt, 1, uploT, diag, dn); |
85 |
} |
} |
86 |
|
|
87 |
SEXP Csparse_Csparse_prod(SEXP a, SEXP b) |
SEXP Csparse_Csparse_prod(SEXP a, SEXP b) |