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 482, Wed Feb 2 15:37:31 2005 UTC revision 488, Wed Feb 2 19:11:51 2005 UTC
# Line 30  Line 30 
30      return ScalarLogical(1);      return ScalarLogical(1);
31  }  }
32    
33    SEXP dgTMatrix_to_dgCMatrix(SEXP x)
34    {
35        SEXP dd = GET_SLOT(x, Matrix_DimSym),
36            iP = GET_SLOT(x, Matrix_iSym),
37            ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dgCMatrix")));
38        int *dims = INTEGER(dd), nnz = length(iP);
39        int *p, *ti = Calloc(nnz, int), m = dims[0], n = dims[1];
40        double *tx = Calloc(nnz, double);
41    
42        SET_SLOT(ans, Matrix_pSym, allocVector(INTSXP, n + 1));
43        SET_SLOT(ans, Matrix_DimSym, duplicate(dd));
44        p = INTEGER(GET_SLOT(ans, Matrix_pSym));
45        triplet_to_col(m, n, nnz, INTEGER(iP),
46                       INTEGER(GET_SLOT(x, Matrix_jSym)),
47                       REAL(GET_SLOT(x, Matrix_xSym)),
48                       p, ti, tx);
49        nnz = p[n];
50        SET_SLOT(ans, Matrix_iSym, allocVector(INTSXP, nnz));
51        Memcpy(INTEGER(GET_SLOT(ans, Matrix_iSym)), ti, nnz);
52        SET_SLOT(ans, Matrix_xSym, allocVector(REALSXP, nnz));
53        Memcpy(REAL(GET_SLOT(ans, Matrix_xSym)), tx, nnz);
54    
55        Free(ti); Free(tx);
56        UNPROTECT(1);
57        return ans;
58    }
59    
60  static void  static void
61  insert_triplets_in_array(int m, int n, int nnz,  insert_triplets_in_array(int m, int n, int nnz,
62                           const int xi[], const int xj[], const double xx[],                           const int xi[], const int xj[], const double xx[],
# Line 79  Line 106 
106      UNPROTECT(1);      UNPROTECT(1);
107      return ans;      return ans;
108  }  }
   

Legend:
Removed from v.482  
changed lines
  Added in v.488

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