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 1548, Mon Sep 11 22:13:07 2006 UTC revision 1555, Wed Sep 13 14:47:28 2006 UTC
# Line 4  Line 4 
4    
5  SEXP Csparse_validate(SEXP x)  SEXP Csparse_validate(SEXP x)
6  {  {
7        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, ncol = length(pslot) - 1,      int j, k, ncol = length(pslot) - 1,
11          *dims = INTEGER(GET_SLOT(x, Matrix_DimSym)),          *dims = INTEGER(GET_SLOT(x, Matrix_DimSym)),
12          nrow, *xp = INTEGER(pslot),          nrow, sorted, *xp = INTEGER(pslot),
13          *xi = INTEGER(islot);          *xi = INTEGER(islot);
14    
15      nrow = dims[0];      nrow = dims[0];
# Line 17  Line 18 
18      if (xp[0] != 0)      if (xp[0] != 0)
19          return mkString(_("first element of slot p must be zero"));          return mkString(_("first element of slot p must be zero"));
20      if (length(islot) != xp[ncol])      if (length(islot) != xp[ncol])
21          return mkString(_("last element of slot p must match length of slots i and x"));          return
22      for (j = 0; j < ncol; j++) {              mkString(_("last element of slot p must match length of slots i and x"));
         if (xp[j] > xp[j+1])  
             return mkString(_("slot p must be non-decreasing"));  
     }  
23      for (j = 0; j < length(islot); j++) {      for (j = 0; j < length(islot); j++) {
24          if (xi[j] < 0 || xi[j] >= nrow)          if (xi[j] < 0 || xi[j] >= nrow)
25              return mkString(_("all row indices must be between 0 and nrow-1"));              return mkString(_("all row indices must be between 0 and nrow-1"));
26      }      }
27        sorted = TRUE;
28        for (j = 0; j < ncol; j++) {
29            if (xp[j] > xp[j+1])
30                return mkString(_("slot p must be non-decreasing"));
31            for (k = xp[j] + 1; k < xp[j + 1]; k++)
32                if (xi[k] < xi[k - 1]) sorted = FALSE;
33        }
34        if (!sorted) cholmod_sort(chx, &c);
35        Free(chx);
36      return ScalarLogical(1);      return ScalarLogical(1);
37  }  }
38    

Legend:
Removed from v.1548  
changed lines
  Added in v.1555

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