SCM

SCM Repository

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

Annotation of /pkg/src/Tsparse.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 922 - (view) (download) (as text)

1 : bates 922 /* Sparse matrices in triplet form */
2 :     #include "Tsparse.h"
3 :     #ifdef USE_CHOLMOD
4 :     #include "chm_common.h"
5 :     #endif /* USE_CHOLMOD */
6 :    
7 :     SEXP Tsparse_validate(SEXP x)
8 :     {
9 :     SEXP
10 :     islot = GET_SLOT(x, Matrix_iSym),
11 :     jslot = GET_SLOT(x, Matrix_jSym),
12 :     dimslot = GET_SLOT(x, Matrix_DimSym);
13 :     int j,
14 :     *dims = INTEGER(dimslot),
15 :     ncol, nrow, nnz = length(islot),
16 :     *xj = INTEGER(jslot),
17 :     *xi = INTEGER(islot);
18 :    
19 :     if (length(jslot) != nnz)
20 :     return mkString(_("lengths of slots i and j must match"));
21 :     if (length(dimslot) != 2)
22 :     return mkString(_("slot Dim must have length 2"));
23 :     nrow = dims[0]; ncol = dims[1];
24 :     for (j = 0; j < nnz; j++) {
25 :     if (xi[j] < 0 || xi[j] >= nrow)
26 :     return mkString(_("all row indices must be between 0 and nrow-1"));
27 :     if (xj[j] < 0 || xj[j] >= ncol)
28 :     return mkString(_("all column indices must be between 0 and ncol-1"));
29 :     }
30 :     return ScalarLogical(1);
31 :     }
32 :    
33 :     SEXP Tsparse_to_Csparse(SEXP x)
34 :     {
35 :     #ifdef USE_CHOLMOD
36 :     cholmod_triplet *chxt = as_cholmod_triplet(x);
37 :     cholmod_sparse *chxs = cholmod_triplet_to_sparse(chxt, chxt->nnz, &c);
38 :    
39 :     Free(chxt);
40 :     return chm_sparse_to_SEXP(chxs, 1);
41 :     #else
42 :     error("General conversion requires CHOLMOD");
43 :     #endif /* USE_CHOLMOD */
44 :     }
45 :    

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