# SCM Repository

[matrix] Diff of /pkg/Matrix/src/Csparse.c
 [matrix] / pkg / Matrix / src / Csparse.c

# Diff of /pkg/Matrix/src/Csparse.c

revision 3192, Tue Sep 27 13:23:32 2016 UTC revision 3204, Tue Feb 7 11:17:03 2017 UTC
# Line 932  Line 932
932      if (csize >= 0 && !isInteger(j))      if (csize >= 0 && !isInteger(j))
933          error(_("Index j must be NULL or integer"));          error(_("Index j must be NULL or integer"));
934
935        /* Must treat 'NA's in i[] and j[] here -- they are *not* treated by Cholmod!
936         * haveNA := ...
937           if(haveNA) {
938             a. i = removeNA(i); j =removeNA(j), and remember where they were
939             b. ans = CHM_SUB(.., i, j)
940             c. add NA rows and/or columns to 'ans' according to
941                place of NA's in i and/or j.
942           } else {
943             ans = CHM_SUB(.....)  // == current code
944           }
945         */
946  #define CHM_SUB(_M_, _i_, _j_)                                  \  #define CHM_SUB(_M_, _i_, _j_)                                  \
947      cholmod_submatrix(_M_,                                      \      cholmod_submatrix(_M_,                                      \
948                        (rsize < 0) ? NULL : INTEGER(_i_), rsize, \                        (rsize < 0) ? NULL : INTEGER(_i_), rsize, \
# Line 941  Line 952
952      if (!chx->stype) {/* non-symmetric Matrix */      if (!chx->stype) {/* non-symmetric Matrix */
953          ans = CHM_SUB(chx, i, j);          ans = CHM_SUB(chx, i, j);
954      }      }
955      else {      else { /* symmetric : "dsCMatrix";
956          /* for now, cholmod_submatrix() only accepts "generalMatrix" */                currently, cholmod_submatrix() only accepts "generalMatrix" */
957          CHM_SP tmp = cholmod_copy(chx, /* stype: */ 0, chx->xtype, &c);          CHM_SP tmp = cholmod_copy(chx, /* stype: */ 0, chx->xtype, &c);
958          ans = CHM_SUB(tmp, i, j);          ans = CHM_SUB(tmp, i, j);
959          cholmod_free_sparse(&tmp, &c);          cholmod_free_sparse(&tmp, &c);
# Line 954  Line 965
965      /*  dn = PROTECT(allocVector(VECSXP, 2)); */      /*  dn = PROTECT(allocVector(VECSXP, 2)); */
966      return chm_sparse_to_SEXP(ans, 1, 0, Rkind, "", /* dimnames: */ R_NilValue);      return chm_sparse_to_SEXP(ans, 1, 0, Rkind, "", /* dimnames: */ R_NilValue);
967  }  }
968    #undef CHM_SUB
969
970  #define _d_Csp_  #define _d_Csp_
971  #include "t_Csparse_subassign.c"  #include "t_Csparse_subassign.c"

Legend:
 Removed from v.3192 changed lines Added in v.3204