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 1618, Fri Oct 6 15:44:01 2006 UTC revision 1654, Fri Oct 27 16:58:15 2006 UTC
# Line 5  Line 5 
5  SEXP Csparse_validate(SEXP x)  SEXP Csparse_validate(SEXP x)
6  {  {
7      /* NB: we do *NOT* check a potential 'x' slot here, at all */      /* NB: we do *NOT* check a potential 'x' slot here, at all */
     cholmod_sparse *chx = as_cholmod_sparse(x);  
8      SEXP pslot = GET_SLOT(x, Matrix_pSym),      SEXP pslot = GET_SLOT(x, Matrix_pSym),
9          islot = GET_SLOT(x, Matrix_iSym);          islot = GET_SLOT(x, Matrix_iSym);
10      int j, k, ncol = length(pslot) - 1,      int j, k, ncol, nrow, sorted,
11          *dims = INTEGER(GET_SLOT(x, Matrix_DimSym)),          *dims = INTEGER(GET_SLOT(x, Matrix_DimSym)),
12          nrow, sorted, *xp = INTEGER(pslot),          *xp = INTEGER(pslot),
13          *xi = INTEGER(islot);          *xi = INTEGER(islot);
14    
15      nrow = dims[0];      nrow = dims[0];
16      if (length(pslot) <= 0)      ncol = dims[1];
17          return mkString(_("slot p must have length > 0"));      if (length(pslot) != dims[1] + 1)
18            return mkString(_("slot p must have length = ncol(.) + 1"));
19      if (xp[0] != 0)      if (xp[0] != 0)
20          return mkString(_("first element of slot p must be zero"));          return mkString(_("first element of slot p must be zero"));
21      if (length(islot) != xp[ncol])      if (length(islot) != xp[ncol])
# Line 32  Line 32 
32          for (k = xp[j] + 1; k < xp[j + 1]; k++)          for (k = xp[j] + 1; k < xp[j + 1]; k++)
33              if (xi[k] < xi[k - 1]) sorted = FALSE;              if (xi[k] < xi[k - 1]) sorted = FALSE;
34      }      }
35      if (!sorted) cholmod_sort(chx, &c);      if (!sorted) {
36            cholmod_sparse *chx = as_cholmod_sparse(x);
37            cholmod_sort(chx, &c);
38      Free(chx);      Free(chx);
39        }
40      return ScalarLogical(1);      return ScalarLogical(1);
41  }  }
42    

Legend:
Removed from v.1618  
changed lines
  Added in v.1654

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