The R Project SVN R-packages

Rev

Rev 4529 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4529 Rev 4530
Line 246... Line 246...
246
    return ans;
246
    return ans;
247
}
247
}
248
 
248
 
249
SEXP dense_to_Csparse(SEXP x)
249
SEXP dense_to_Csparse(SEXP x)
250
{
250
{
251
    cholmod_dense *chxd = as_cholmod_x_dense(PROTECT(mMatrix_as_geMatrix(x)));
251
    CHM_DN chxd = AS_CHM_DN(PROTECT(mMatrix_as_geMatrix(x)));
252
 
252
 
253
    /* cholmod_dense_to_sparse() in CHOLMOD/Core/ below does only work for
253
    /* cholmod_dense_to_sparse() in CHOLMOD/Core/ below does only work for
254
       "REAL" 'xtypes', i.e. *not* for "nMatrix".
254
       "REAL" 'xtypes', i.e. *not* for "nMatrix".
255
       ===> need "_x" in above call.
255
       ===> need "_x" in above call.
256
 
256
 
Line 258... Line 258...
258
       as_geMatrix() above.  Note that this is already a *waste* for
258
       as_geMatrix() above.  Note that this is already a *waste* for
259
       symmetric matrices; However, we could conceivably use an
259
       symmetric matrices; However, we could conceivably use an
260
       enhanced cholmod_dense_to_sparse(), with an extra boolean
260
       enhanced cholmod_dense_to_sparse(), with an extra boolean
261
       argument for symmetry.
261
       argument for symmetry.
262
    */
262
    */
263
    cholmod_sparse *chxs = cholmod_dense_to_sparse(chxd, 1, &c);
263
    CHM_SP chxs = cholmod_dense_to_sparse(chxd, 1, &c);
264
    int Rkind = (chxd->xtype == CHOLMOD_REAL) ? Real_KIND(x) : 0;
264
    int Rkind = (chxd->xtype == CHOLMOD_REAL) ? Real_KIND(x) : 0;
265
 
265
 
266
    Free(chxd); UNPROTECT(1);
266
    UNPROTECT(1);
267
    /* chm_sparse_to_SEXP() *could* deal with symmetric
267
    /* chm_sparse_to_SEXP() *could* deal with symmetric
268
     * if chxs had such an stype; and we should be able to use uplo below */
268
     * if chxs had such an stype; and we should be able to use uplo below */
269
    return chm_sparse_to_SEXP(chxs, 1, 0/*TODO: uplo_P(x) if x has an uplo slot*/,
269
    return chm_sparse_to_SEXP(chxs, 1, 0/*TODO: uplo_P(x) if x has an uplo slot*/,
270
			      Rkind, "",
270
			      Rkind, "",
271
			      isMatrix(x) ? getAttrib(x, R_DimNamesSymbol)
271
			      isMatrix(x) ? getAttrib(x, R_DimNamesSymbol)