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 3142, Wed Sep 2 21:23:29 2015 UTC revision 3143, Wed Sep 2 21:29:32 2015 UTC
# Line 222  Line 222 
222  SEXP nz2Csparse(SEXP x, enum x_slot_kind r_kind)  SEXP nz2Csparse(SEXP x, enum x_slot_kind r_kind)
223  {  {
224      const char *cl_x = class_P(x);      const char *cl_x = class_P(x);
225      if(cl_x[0] != 'n') error(_("not a 'n.CMatrix'"));      // quick check - if ok, fast
226      if(cl_x[2] != 'C') error(_("not a CsparseMatrix"));      if(cl_x[0] != 'n' || cl_x[2] != 'C') {
227            // e.g. class = "A", from  setClass("A", contains = "ngCMatrix")
228            static const char *valid[] = { MATRIX_VALID_nCsparse, ""};
229            int ctype = Matrix_check_class_etc(x, valid);
230            if(ctype < 0)
231                error(_("not a 'n.CMatrix'"));
232            else // fine : get a valid  cl_x  class_P()-like string :
233                cl_x = valid[ctype];
234        }
235      int nnz = LENGTH(GET_SLOT(x, Matrix_iSym));      int nnz = LENGTH(GET_SLOT(x, Matrix_iSym));
236      SEXP ans;      SEXP ans;
237      char *ncl = alloca(strlen(cl_x) + 1); /* not much memory required */      char *ncl = alloca(strlen(cl_x) + 1); /* not much memory required */
# Line 435  Line 443 
443          cha = AS_CHM_SP(a),          cha = AS_CHM_SP(a),
444          chb = AS_CHM_SP(b), chc;          chb = AS_CHM_SP(b), chc;
445      R_CheckStack();      R_CheckStack();
     // const char *cl_a = class_P(a), *cl_b = class_P(b);  
446      static const char *valid_tri[] = { MATRIX_VALID_tri_Csparse, "" };      static const char *valid_tri[] = { MATRIX_VALID_tri_Csparse, "" };
447      char diag[] = {'\0', '\0'};      char diag[] = {'\0', '\0'};
448      int uploT = 0, nprot = 1,      int uploT = 0, nprot = 1,
# Line 775  Line 782 
782  {  {
783      const char *cl = class_P(x);      const char *cl = class_P(x);
784      /* dtCMatrix, etc; [1] = the second character =?= 't' for triangular */      /* dtCMatrix, etc; [1] = the second character =?= 't' for triangular */
785      int tr = (cl[1] == 't');      int tr = (cl[1] == 't'); // FIXME - rather  Matrix_check_class_etc(..)
786      CHM_SP chx = AS_CHM_SP__(x);      CHM_SP chx = AS_CHM_SP__(x);
787      CHM_SP ans = cholmod_copy(chx, chx->stype, chx->xtype, &c);      CHM_SP ans = cholmod_copy(chx, chx->stype, chx->xtype, &c);
788      double dtol = asReal(tol);      double dtol = asReal(tol);

Legend:
Removed from v.3142  
changed lines
  Added in v.3143

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