SCM

SCM Repository

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

Diff of /pkg/src/dgCMatrix.c

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

revision 491, Wed Feb 2 19:40:26 2005 UTC revision 492, Thu Feb 3 14:24:03 2005 UTC
# Line 50  Line 50 
50      double *xVal;      double *xVal;
51    
52      SET_SLOT(ans, Matrix_factorSym, allocVector(VECSXP, 0));      SET_SLOT(ans, Matrix_factorSym, allocVector(VECSXP, 0));
53        SET_SLOT(ans, Matrix_DimSym, allocVector(INTSXP, 2));
54        SET_SLOT(ans, Matrix_uploSym, mkString("L"));
55      maxnz = (ncol * (ncol + 1))/2;      maxnz = (ncol * (ncol + 1))/2;
56      iVal = Calloc(maxnz, int); xVal = Calloc(maxnz, double);      iVal = Calloc(maxnz, int); xVal = Calloc(maxnz, double);
57      SET_SLOT(ans, Matrix_pSym, allocVector(INTSXP, ncol + 1));      SET_SLOT(ans, Matrix_pSym, allocVector(INTSXP, ncol + 1));
# Line 115  Line 117 
117      double *xVal, *xtmp;      double *xVal, *xtmp;
118    
119      SET_SLOT(ans, Matrix_factorSym, allocVector(VECSXP, 0));      SET_SLOT(ans, Matrix_factorSym, allocVector(VECSXP, 0));
120        SET_SLOT(ans, Matrix_DimSym, allocVector(INTSXP, 2));
121      ntrip = nrow;               /* number of triplets */      ntrip = nrow;               /* number of triplets */
122      for (j = 0; j < ncol; j++) {      for (j = 0; j < ncol; j++) {
123          int nzj = xp[j+1] - xp[j];          int nzj = xp[j+1] - xp[j];
# Line 154  Line 157 
157      SET_SLOT(ans, Matrix_xSym, allocVector(REALSXP, nnz));      SET_SLOT(ans, Matrix_xSym, allocVector(REALSXP, nnz));
158      Memcpy(INTEGER(GET_SLOT(ans, Matrix_iSym)), itmp, nnz);      Memcpy(INTEGER(GET_SLOT(ans, Matrix_iSym)), itmp, nnz);
159      Memcpy(REAL(GET_SLOT(ans, Matrix_xSym)), xtmp, nnz);      Memcpy(REAL(GET_SLOT(ans, Matrix_xSym)), xtmp, nnz);
     SET_SLOT(ans, Matrix_DimSym, allocVector(INTSXP, 2));  
160      dims = INTEGER(GET_SLOT(ans, Matrix_DimSym));      dims = INTEGER(GET_SLOT(ans, Matrix_DimSym));
161      dims[0] = dims[1] = nrow;      dims[0] = dims[1] = nrow;
162      Free(itmp); Free(xtmp); Free(iVal); Free(jVal); Free(xVal);      Free(itmp); Free(xtmp); Free(iVal); Free(jVal); Free(xVal);
# Line 276  Line 278 
278          error("A must be a numeric matrix");          error("A must be a numeric matrix");
279      nrow = adims[0]; ncol = adims[1];      nrow = adims[0]; ncol = adims[1];
280      SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));      SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
281        SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));
282      SET_SLOT(val, Matrix_pSym, allocVector(INTSXP, ncol + 1));      SET_SLOT(val, Matrix_pSym, allocVector(INTSXP, ncol + 1));
283      vp = INTEGER(GET_SLOT(val, Matrix_pSym));      vp = INTEGER(GET_SLOT(val, Matrix_pSym));
284      maxnz = nrow * ncol;      maxnz = nrow * ncol;
# Line 349  Line 352 
352    
353  SEXP csc_transpose(SEXP x)  SEXP csc_transpose(SEXP x)
354  {  {
355      SEXP      SEXP ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dgCMatrix"))),
         ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dgCMatrix"))),  
356          islot = GET_SLOT(x, Matrix_iSym);          islot = GET_SLOT(x, Matrix_iSym);
357      int nnz = length(islot),      int *adims, *xdims = INTEGER(GET_SLOT(x, Matrix_DimSym)),
358          *adims = INTEGER(GET_SLOT(ans, Matrix_DimSym)),          nnz = length(islot);
         *xdims = INTEGER(GET_SLOT(x, Matrix_DimSym));  
359    
360        SET_SLOT(ans, Matrix_DimSym, allocVector(INTSXP, 2));
361        adims = INTEGER(GET_SLOT(ans, Matrix_DimSym));
362      adims[0] = xdims[1]; adims[1] = xdims[0];      adims[0] = xdims[1]; adims[1] = xdims[0];
363      SET_SLOT(ans, Matrix_factorSym, allocVector(VECSXP, 0));      SET_SLOT(ans, Matrix_factorSym, allocVector(VECSXP, 0));
364      SET_SLOT(ans, Matrix_pSym, allocVector(INTSXP, xdims[0] + 1));      SET_SLOT(ans, Matrix_pSym, allocVector(INTSXP, xdims[0] + 1));

Legend:
Removed from v.491  
changed lines
  Added in v.492

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