SCM

SCM Repository

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

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

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

revision 2661, Wed Apr 6 06:55:54 2011 UTC revision 2725, Sat Oct 8 19:48:44 2011 UTC
# Line 1  Line 1 
1                          /* Sparse matrices in compressed column-oriented form */                          /* Sparse matrices in compressed column-oriented form */
2    
3  #include "Csparse.h"  #include "Csparse.h"
4  #include "Tsparse.h"  #include "Tsparse.h"
5  #include "chm_common.h"  #include "chm_common.h"
# Line 612  Line 613 
613                                /* FIXME: drops dimnames */ R_NilValue);                                /* FIXME: drops dimnames */ R_NilValue);
614  }  }
615    
616  /**  #define _d_Csp_
617   * Subassignment:  x[i,j]  <- value  #include "t_Csparse_subassign.c"
618   *  
619   * @param x  #define _l_Csp_
620   * @param i_ integer row    index 0-origin vector (as returned from R .ind.prep2())  #include "t_Csparse_subassign.c"
621   * @param j_ integer column index 0-origin vector  
622   * @param value currently must be a dsparseVector {which is recycled if needed}  #define _i_Csp_
623   *  #include "t_Csparse_subassign.c"
624   * @return a Csparse matrix like x, but with the values replaced  
625   */  #define _n_Csp_
626  SEXP Csparse_subassign(SEXP x, SEXP i_, SEXP j_, SEXP value)  #include "t_Csparse_subassign.c"
627  {  
628      static const char  #define _z_Csp_
629          *valid_cM [] = {"dgCMatrix",// the only one, for "the moment", more later  #include "t_Csparse_subassign.c"
                         ""},  
         *valid_spv[] = {"dsparseVector",  
                         ""};  
   
     int ctype = Matrix_check_class_etc(x, valid_cM);  
     if (ctype < 0)  
         error(_("invalid class of 'x' in Csparse_subassign()"));  
     // value: assume a  "dsparseVector" for now -- slots: (i, length, x)  
     ctype = Matrix_check_class_etc(value, valid_spv);  
     if (ctype < 0)  
         error(_("invalid class of 'value' in Csparse_subassign()"));  
   
     SEXP ans,  
         pslot = GET_SLOT(x, Matrix_pSym),  
         islot = GET_SLOT(x, Matrix_iSym),  
         i_cp = PROTECT((TYPEOF(i_) == INTSXP) ?  
                        duplicate(i_) : coerceVector(i_, INTSXP)),  
         j_cp = PROTECT((TYPEOF(j_) == INTSXP) ?  
                        duplicate(j_) : coerceVector(j_, INTSXP)),  
         // for d.CMatrix and l.CMatrix  but not n.CMatrix  
         xslot = GET_SLOT(x, Matrix_xSym);  
630    
     int *dims = INTEGER(GET_SLOT(x, Matrix_DimSym)),  
         nrow = dims[0],  
         ncol = dims[1],  
         *xp = INTEGER(pslot),  
         *xi = INTEGER(islot),  
         *ii = INTEGER(i_cp), len_i = LENGTH(i_cp),  
         *jj = INTEGER(j_cp), len_j = LENGTH(j_cp),  
         i, j, k;  
     int    *val_i = INTEGER(GET_SLOT(value, Matrix_iSym));  
     double *val_x =   REAL (GET_SLOT(value, Matrix_xSym));  
     int len_val = asInteger(GET_SLOT(value, Matrix_lengthSym));  
     int p_last = xp[0];  
   
     // for d.CMatrix only:  
     double *xx = REAL(xslot);  
     double ind; // the index that goes all the way from 1:(len_i * len_j)  
631    
     PROTECT(ans = duplicate(x));  
     for(j = 0; j < ncol; j++) {  
     }  
     UNPROTECT(3);  
     return ans;  
 }  
632    
633  SEXP Csparse_MatrixMarket(SEXP x, SEXP fname)  SEXP Csparse_MatrixMarket(SEXP x, SEXP fname)
634  {  {

Legend:
Removed from v.2661  
changed lines
  Added in v.2725

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