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 3256, Sat Mar 17 06:08:36 2018 UTC revision 3257, Sat Mar 17 06:10:05 2018 UTC
# Line 247  Line 247 
247    
248  SEXP dense_to_Csparse(SEXP x)  SEXP dense_to_Csparse(SEXP x)
249  {  {
250      CHM_DN chxd = AS_CHM_xDN(PROTECT(mMatrix_as_geMatrix(x)));      SEXP ge_x = PROTECT(mMatrix_as_geMatrix(x)),
251            Dim = GET_SLOT(ge_x, Matrix_DimSym);
252        int *dims = INTEGER(Dim);
253        Rboolean longi = (dims[0] * (double)dims[1] > INT_MAX);
254        // int itype = longi ? CHOLMOD_LONG : CHOLMOD_INT;
255        CHM_DN chxd = AS_CHM_xDN(ge_x); // cholmod_dense (has no itype)
256        CHM_SP chxs;
257      /* cholmod_dense_to_sparse() in CHOLMOD/Core/ below does only work for      /* cholmod_dense_to_sparse() in CHOLMOD/Core/ below does only work for
258         "REAL" 'xtypes', i.e. *not* for "nMatrix".         "REAL" 'xtypes', i.e. *not* for "nMatrix".
259         ===> need "_x" in above AS_CHM_xDN() call.         ===> need "_x" in above AS_CHM_xDN() call.
# Line 258  Line 264 
264         enhanced cholmod_dense_to_sparse(), with an extra boolean         enhanced cholmod_dense_to_sparse(), with an extra boolean
265         argument for symmetry.         argument for symmetry.
266      */      */
267      // TODO: When prod(dim(.)) > INT_MAX, we *must* use but cannot --> need itype = CHOLMOD_LONG  #define DLONG
268      // ---- CHM_SP chxs = cholmod_l_dense_to_sparse(chxd, 1, &c);  /* You can try defining DLONG -- then just get a seg.fault :
269      CHM_SP chxs = cholmod_dense_to_sparse(chxd, 1, &c);   *  I think it is because of this in  ./CHOLMOD/Include/cholmod_core.h :
270     *
271     The itype of all parameters for all CHOLMOD routines must match.
272     --- ^^^^^ ------------------------------------------------------
273     but then as_cholmod_dense should *not* make a difference: cholmod_dense has *no* itype   (????)
274    */
275        if(longi) { // calling cholmod_dense_to_sparse() gives wrong matrix
276    #ifdef DLONG
277            chxs = cholmod_l_dense_to_sparse(chxd, 1, &cl);
278            // in gdb, I found that 'chxs' seems "basically empty": all
279            // p chxs->foo   give ''Cannot access memory at address 0x....''
280            // for now rather give error:
281            if(cl.status)
282                error(_("dense_to_Csparse(<LARGE>): cholmod_l_dense_to_sparse failure status=%d"),
283                      cl.status);
284    #else
285            error(_("Matrix dimension %d x %d (= %g) too large [FIXME calling cholmod_l_dense_to_sparse]"),
286                  m,n, m * (double)n);
287    #endif
288        } else { // fits, using integer (instead of long int) 'itype'
289            chxs = cholmod_dense_to_sparse(chxd, 1, &c);
290        }
291    
292      int Rkind = (chxd->xtype == CHOLMOD_REAL) ? Real_KIND2(x) : 0;      int Rkind = (chxd->xtype == CHOLMOD_REAL) ? Real_KIND2(x) : 0;
293      /* Note: when 'x' was integer Matrix, Real_KIND(x) = -1, but *_KIND2(.) = 0 */      /* Note: when 'x' was integer Matrix, Real_KIND(x) = -1, but *_KIND2(.) = 0 */

Legend:
Removed from v.3256  
changed lines
  Added in v.3257

root@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