SCM

SCM Repository

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

Diff of /pkg/src/dgTMatrix.c

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

revision 922, Sun Sep 18 16:33:54 2005 UTC revision 1059, Wed Nov 23 22:20:13 2005 UTC
# Line 1  Line 1 
1  #include "dgTMatrix.h"  #include "dgTMatrix.h"
2    
 #ifdef USE_CHOLMOD  
3  #include "chm_common.h"  #include "chm_common.h"
4  #include "Tsparse.h"  #include "Tsparse.h"
 #endif /* USE_CHOLMOD */  
5    
6  SEXP dgTMatrix_validate(SEXP x)  SEXP dgTMatrix_validate(SEXP x)
7  {  {
# Line 18  Line 16 
16    
17  SEXP dgTMatrix_to_dgCMatrix(SEXP x)  SEXP dgTMatrix_to_dgCMatrix(SEXP x)
18  {  {
 #ifdef USE_CHOLMOD  
19      return Tsparse_to_Csparse(x);      return Tsparse_to_Csparse(x);
 #else  
     SEXP dd = GET_SLOT(x, Matrix_DimSym),  
         iP = GET_SLOT(x, Matrix_iSym),  
         ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dgCMatrix")));  
     int *dims = INTEGER(dd), nnz = length(iP);  
     int *p = INTEGER(GET_SLOT(ans, Matrix_pSym)),  
         *ti = Calloc(nnz, int), m = dims[0], n = dims[1];  
     double *tx = Calloc(nnz, double);  
   
     SET_SLOT(ans, Matrix_pSym, allocVector(INTSXP, n + 1));  
     SET_SLOT(ans, Matrix_DimSym, duplicate(dd));  
     triplet_to_col(m, n, nnz, INTEGER(iP),  
                    INTEGER(GET_SLOT(x, Matrix_jSym)),  
                    REAL(GET_SLOT(x, Matrix_xSym)),  
                    p, ti, tx);  
     nnz = p[n];  
     SET_SLOT(ans, Matrix_iSym, allocVector(INTSXP, nnz));  
     Memcpy(INTEGER(GET_SLOT(ans, Matrix_iSym)), ti, nnz);  
     SET_SLOT(ans, Matrix_xSym, allocVector(REALSXP, nnz));  
     Memcpy(REAL(GET_SLOT(ans, Matrix_xSym)), tx, nnz);  
   
     Free(ti); Free(tx);  
     UNPROTECT(1);  
     return ans;  
 #endif /* USE_CHOLMOD */  
20  }  }
21    
22  static void  static void

Legend:
Removed from v.922  
changed lines
  Added in v.1059

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge