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 2725, Sat Oct 8 19:48:44 2011 UTC revision 2784, Fri Jun 8 17:01:25 2012 UTC
# Line 566  Line 566 
566      }      }
567      else { /* triangular with diag='N'): now drop the diagonal */      else { /* triangular with diag='N'): now drop the diagonal */
568          /* duplicate, since chx will be modified: */          /* duplicate, since chx will be modified: */
569          CHM_SP chx = AS_CHM_SP__(duplicate(x));          SEXP xx = PROTECT(duplicate(x));
570            CHM_SP chx = AS_CHM_SP__(xx);
571          int uploT = (*uplo_P(x) == 'U') ? 1 : -1,          int uploT = (*uplo_P(x) == 'U') ? 1 : -1,
572              Rkind = (chx->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0;              Rkind = (chx->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0;
573          R_CheckStack();          R_CheckStack();
574    
575          chm_diagN2U(chx, uploT, /* do_realloc */ FALSE);          chm_diagN2U(chx, uploT, /* do_realloc */ FALSE);
576    
577            UNPROTECT(1);
578          return chm_sparse_to_SEXP(chx, /*dofree*/ 0/* or 1 ?? */,          return chm_sparse_to_SEXP(chx, /*dofree*/ 0/* or 1 ?? */,
579                                    uploT, Rkind, "U",                                    uploT, Rkind, "U",
580                                    GET_SLOT(x, Matrix_DimNamesSym));                                    GET_SLOT(x, Matrix_DimNamesSym));
# Line 601  Line 603 
603      if (csize >= 0 && !isInteger(j))      if (csize >= 0 && !isInteger(j))
604          error(_("Index j must be NULL or integer"));          error(_("Index j must be NULL or integer"));
605    
606      if (chx->stype) /* symmetricMatrix */      if (!chx->stype) {/* non-symmetric Matrix */
         /* for now, cholmod_submatrix() only accepts "generalMatrix" */  
         chx = cholmod_copy(chx, /* stype: */ 0, chx->xtype, &c);  
   
607      return chm_sparse_to_SEXP(cholmod_submatrix(chx,      return chm_sparse_to_SEXP(cholmod_submatrix(chx,
608                                  (rsize < 0) ? NULL : INTEGER(i), rsize,                                  (rsize < 0) ? NULL : INTEGER(i), rsize,
609                                  (csize < 0) ? NULL : INTEGER(j), csize,                                  (csize < 0) ? NULL : INTEGER(j), csize,
# Line 612  Line 611 
611                                1, 0, Rkind, "",                                1, 0, Rkind, "",
612                                /* FIXME: drops dimnames */ R_NilValue);                                /* FIXME: drops dimnames */ R_NilValue);
613  }  }
614                                    /* for now, cholmod_submatrix() only accepts "generalMatrix" */
615        CHM_SP tmp = cholmod_copy(chx, /* stype: */ 0, chx->xtype, &c);
616        CHM_SP ans = cholmod_submatrix(tmp,
617                                       (rsize < 0) ? NULL : INTEGER(i), rsize,
618                                       (csize < 0) ? NULL : INTEGER(j), csize,
619                                       TRUE, TRUE, &c);
620        cholmod_free_sparse(&tmp, &c);
621        return chm_sparse_to_SEXP(ans, 1, 0, Rkind, "", R_NilValue);
622    }
623    
624  #define _d_Csp_  #define _d_Csp_
625  #include "t_Csparse_subassign.c"  #include "t_Csparse_subassign.c"
# Line 712  Line 720 
720      case diag_backpermuted:      case diag_backpermuted:
721          for_DIAG(v[i] = x_x[i_from]);          for_DIAG(v[i] = x_x[i_from]);
722    
723          warning(_("resultKind = 'diagBack' (back-permuted) is experimental"));          warning(_("%s = '%s' (back-permuted) is experimental"),
724                    "resultKind", "diagBack");
725          /* now back_permute : */          /* now back_permute : */
726          for(i = 0; i < n; i++) {          for(i = 0; i < n; i++) {
727              double tmp = v[i]; v[i] = v[perm[i]]; v[perm[i]] = tmp;              double tmp = v[i]; v[i] = v[perm[i]]; v[perm[i]] = tmp;

Legend:
Removed from v.2725  
changed lines
  Added in v.2784

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