SCM

SCM Repository

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

Diff of /pkg/src/lgCMatrix.c

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

revision 1944, Wed Jul 4 16:27:48 2007 UTC revision 1945, Wed Jul 4 18:07:07 2007 UTC
# Line 5  Line 5 
5    
6  SEXP lcsc_to_matrix(SEXP x)  SEXP lcsc_to_matrix(SEXP x)
7  {  {
8      SEXP ans, pslot = GET_SLOT(x, Matrix_pSym);      SEXP ans, pslot = GET_SLOT(x, Matrix_pSym),
9            dn = GET_SLOT(x, Matrix_DimNamesSym);
10      int j, ncol = length(pslot) - 1,      int j, ncol = length(pslot) - 1,
11          nrow = INTEGER(GET_SLOT(x, Matrix_DimSym))[0],          nrow = INTEGER(GET_SLOT(x, Matrix_DimSym))[0],
12          *xp = INTEGER(pslot),          *xp = INTEGER(pslot),
# Line 19  Line 20 
20          for (ind = xp[j]; ind < xp[j+1]; ind++)          for (ind = xp[j]; ind < xp[j+1]; ind++)
21              ax[j * nrow + xi[ind]] = xx[ind];              ax[j * nrow + xi[ind]] = xx[ind];
22      }      }
23        if (!(isNull(VECTOR_ELT(dn,0)) && isNull(VECTOR_ELT(dn,1))))
24            setAttrib(ans, R_DimNamesSymbol, duplicate(dn));
25      UNPROTECT(1);      UNPROTECT(1);
26      return ans;      return ans;
27  }  }
# Line 26  Line 29 
29  /* as above,  '1' instead of 'x' slot: */  /* as above,  '1' instead of 'x' slot: */
30  SEXP ncsc_to_matrix(SEXP x)  SEXP ncsc_to_matrix(SEXP x)
31  {  {
32      SEXP ans, pslot = GET_SLOT(x, Matrix_pSym);      SEXP ans, pslot = GET_SLOT(x, Matrix_pSym),
33            dn = GET_SLOT(x, Matrix_DimNamesSym);
34      int j, ncol = length(pslot) - 1,      int j, ncol = length(pslot) - 1,
35          nrow = INTEGER(GET_SLOT(x, Matrix_DimSym))[0],          nrow = INTEGER(GET_SLOT(x, Matrix_DimSym))[0],
36          *xp = INTEGER(pslot),          *xp = INTEGER(pslot),
# Line 40  Line 44 
44          for (ind = xp[j]; ind < xp[j+1]; ind++)          for (ind = xp[j]; ind < xp[j+1]; ind++)
45              ax[j * nrow + xi[ind]] = 1;              ax[j * nrow + xi[ind]] = 1;
46      }      }
47        if (!(isNull(VECTOR_ELT(dn,0)) && isNull(VECTOR_ELT(dn,1))))
48            setAttrib(ans, R_DimNamesSymbol, duplicate(dn));
49      UNPROTECT(1);      UNPROTECT(1);
50      return ans;      return ans;
51  }  }

Legend:
Removed from v.1944  
changed lines
  Added in v.1945

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