SCM

SCM Repository

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

Annotation of /pkg/src/dgTMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (view) (download) (as text)
Original Path: pkg/src/triplet.c

1 : bates 10 /* Sparse matrices in triplet form */
2 :     #include "triplet.h"
3 :    
4 :     SEXP triplet_validate(SEXP x)
5 :     {
6 :     SEXP
7 :     islot = GET_SLOT(x, Matrix_iSym),
8 :     jslot = GET_SLOT(x, Matrix_jSym),
9 :     xslot = GET_SLOT(x, Matrix_xSym),
10 :     dimslot = GET_SLOT(x, Matrix_DimSym);
11 :     int j,
12 :     *dims = INTEGER(dimslot),
13 :     ncol, nrow, nnz = length(islot),
14 :     *xj = INTEGER(jslot),
15 :     *xi = INTEGER(islot);
16 :    
17 :     if (length(xslot) != nnz || length(jslot) != nnz)
18 :     return ScalarString(mkChar("lengths of slots i, j, and x must match"));
19 :     if (length(dimslot) != 2)
20 :     return ScalarString(mkChar("slot Dim must have length 2"));
21 :     nrow = dims[0]; ncol = dims[1];
22 :     for (j = 0; j < nnz; j++) {
23 :     if (xi[j] < 0 || xi[j] >= nrow)
24 :     return ScalarString(
25 :     mkChar("all row indices must be between 0 and nrow-1"));
26 :     if (xj[j] < 0 || xj[j] >= ncol)
27 :     return ScalarString(
28 :     mkChar("all column indices must be between 0 and ncol-1"));
29 :     }
30 :     return ScalarLogical(1);
31 :     }

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