SCM

SCM Repository

[matrix] Diff of /pkg/Matrix/src/dense.c
ViewVC logotype

Diff of /pkg/Matrix/src/dense.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1724, Sat Jan 13 21:06:51 2007 UTC revision 1725, Wed Jan 17 08:01:10 2007 UTC
# Line 1  Line 1 
1  #include "dense.h"  #include "dense.h"
2    #include "Mutils.h"
3  #include "chm_common.h"  #include "chm_common.h"
4    
5  /**  /**
# Line 245  Line 246 
246      return ans;      return ans;
247  }  }
248    
 /* FIXME: 'dense_' really still means 'ddense_' .. : */  
249  SEXP dense_to_Csparse(SEXP x)  SEXP dense_to_Csparse(SEXP x)
250  {  {
251      cholmod_dense *chxd = as_cholmod_dense(PROTECT(mMatrix_as_dgeMatrix(x)));      cholmod_dense *chxd = as_cholmod_dense(PROTECT(mMatrix_as_geMatrix(x)));
252        /* cholmod_dense_to_sparse() in CHOLMOD/Core/ does work for all 'xtypes'
253           including "nMatrix", but cannot keep symmetric / triangular, hence the
254           as_geMatrix() above.
255           Note that this is already a *waste* for symmetric matrices;
256           However, we could conceivable use an enhanced cholmod_dense_to_sparse(),
257           with an extra boolean argument for symmetry.
258        */
259      cholmod_sparse *chxs = cholmod_dense_to_sparse(chxd, 1, &c);      cholmod_sparse *chxs = cholmod_dense_to_sparse(chxd, 1, &c);
260      int Rkind = 0; /* FIXME : Real_kind(x) does not work:      int Rkind = (chxd->xtype == CHOLMOD_REAL) ? Real_KIND(x) : 0;
                     * (chxd->xtype == CHOLMOD_REAL) ? Real_kind(x) : 0; */  
261    
262      Free(chxd); UNPROTECT(1);      Free(chxd); UNPROTECT(1);
263      return chm_sparse_to_SEXP(chxs, 1, 0, Rkind, "",      /* chm_sparse_to_SEXP() *could* deal with symmetric
264         * if chxs had such an stype; and we should be able to use uplo below */
265        return chm_sparse_to_SEXP(chxs, 1, 0/*TODO: uplo_P(x) if x has an uplo slot*/,
266                                  Rkind, "",
267                                isMatrix(x) ? getAttrib(x, R_DimNamesSymbol)                                isMatrix(x) ? getAttrib(x, R_DimNamesSymbol)
268                                : GET_SLOT(x, Matrix_DimNamesSym));                                : GET_SLOT(x, Matrix_DimNamesSym));
269  }  }

Legend:
Removed from v.1724  
changed lines
  Added in v.1725

R-Forge@R-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge