SCM

SCM Repository

[matrix] Diff of /pkg/src/dsCMatrix.c
ViewVC logotype

Diff of /pkg/src/dsCMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 592, Thu Mar 3 05:16:50 2005 UTC revision 741, Tue May 17 17:44:02 2005 UTC
# Line 38  Line 38 
38      SET_SLOT(val, Matrix_uploSym, mkString("L"));      SET_SLOT(val, Matrix_uploSym, mkString("L"));
39      SET_SLOT(val, Matrix_diagSym, mkString("U"));      SET_SLOT(val, Matrix_diagSym, mkString("U"));
40      SET_SLOT(val, Matrix_DimSym, duplicate(GET_SLOT(x, Matrix_DimSym)));      SET_SLOT(val, Matrix_DimSym, duplicate(GET_SLOT(x, Matrix_DimSym)));
41      SET_SLOT(val, Matrix_ParentSym, allocVector(INTSXP, n));      Parent = INTEGER(ALLOC_SLOT(val, Matrix_ParentSym, INTSXP, n));
42      Parent = INTEGER(GET_SLOT(val, Matrix_ParentSym));      Lp = INTEGER(ALLOC_SLOT(val, Matrix_pSym, INTSXP, n + 1));
43      SET_SLOT(val, Matrix_pSym, allocVector(INTSXP, n + 1));      P = INTEGER(ALLOC_SLOT(val, Matrix_permSym, INTSXP, n));
     Lp = INTEGER(GET_SLOT(val, Matrix_pSym));  
     SET_SLOT(val, Matrix_permSym, allocVector(INTSXP, n));  
     P = INTEGER(GET_SLOT(val, Matrix_permSym));  
44      if (piv) {      if (piv) {
45          SEXP trip = PROTECT(dsCMatrix_to_dgTMatrix(x));          SEXP trip = PROTECT(dsCMatrix_to_dgTMatrix(x));
46          SEXP Ti = GET_SLOT(trip, Matrix_iSym);          SEXP Ti = GET_SLOT(trip, Matrix_iSym);
# Line 89  Line 86 
86      return set_factors(xorig, val, "Cholesky");      return set_factors(xorig, val, "Cholesky");
87  }  }
88    
89  SEXP dsCMatrix_matrix_solve(SEXP a, SEXP b)  SEXP dsCMatrix_matrix_solve(SEXP a, SEXP b, SEXP classed)
90  {  {
91        int cl = asLogical(classed);
92      SEXP Chol = get_factors(a, "Cholesky"), perm,      SEXP Chol = get_factors(a, "Cholesky"), perm,
93          val = PROTECT(duplicate(b));          bdP = cl ? GET_SLOT(b, Matrix_DimSym) : getAttrib(b, R_DimSymbol),
94            val = PROTECT(NEW_OBJECT(MAKE_CLASS("dgeMatrix")));
95      int *adims = INTEGER(GET_SLOT(a, Matrix_DimSym)),      int *adims = INTEGER(GET_SLOT(a, Matrix_DimSym)),
96          *bdims = INTEGER(getAttrib(b, R_DimSymbol)),          *bdims = INTEGER(bdP),
97          *Li, *Lp, j, n = adims[1], ncol = bdims[1], piv;          *Li, *Lp, j, piv;
98      double *Lx, *D, *in = REAL(b), *out = REAL(val), *tmp = (double *) NULL;      int n = adims[1], ncol = bdims[1];
99        double *Lx, *D, *in = REAL(cl ? GET_SLOT(b, Matrix_xSym) : b),
100            *out = REAL(ALLOC_SLOT(val, Matrix_xSym, REALSXP, n * ncol)),
101            *tmp = (double *) NULL;
102    
103      if (!(isReal(b) && isMatrix(b)))      if (!cl && !(isReal(b) && isMatrix(b)))
104          error(_("Argument b must be a numeric matrix"));          error(_("Argument b must be a numeric matrix"));
105      if (*adims != *bdims || bdims[1] < 1 || *adims < 1)      if (*adims != *bdims || ncol < 1 || *adims < 1)
106          error(_("Dimensions of system to be solved are inconsistent"));          error(_("Dimensions of system to be solved are inconsistent"));
107      if (Chol == R_NilValue) Chol = dsCMatrix_chol(a, ScalarLogical(1));      if (Chol == R_NilValue) Chol = dsCMatrix_chol(a, ScalarLogical(1));
108        SET_SLOT(val, Matrix_DimSym, duplicate(bdP));
109      perm = GET_SLOT(Chol, Matrix_permSym);      perm = GET_SLOT(Chol, Matrix_permSym);
110      piv = length(perm);      piv = length(perm);
111      if (piv) tmp = Calloc(n, double);      if (piv) tmp = Calloc(n, double);
# Line 139  Line 142 
142      adims[0] = xdims[1]; adims[1] = xdims[0];      adims[0] = xdims[1]; adims[1] = xdims[0];
143      if (CHAR(asChar(GET_SLOT(x, Matrix_uploSym)))[0] == 'U')      if (CHAR(asChar(GET_SLOT(x, Matrix_uploSym)))[0] == 'U')
144          SET_SLOT(ans, Matrix_uploSym, mkString("L"));          SET_SLOT(ans, Matrix_uploSym, mkString("L"));
145        else
146            SET_SLOT(ans, Matrix_uploSym, mkString("U"));
147      csc_compTr(xdims[0], xdims[1], nnz,      csc_compTr(xdims[0], xdims[1], nnz,
148                 INTEGER(GET_SLOT(x, Matrix_pSym)), INTEGER(islot),                 INTEGER(GET_SLOT(x, Matrix_pSym)), INTEGER(islot),
149                 REAL(GET_SLOT(x, Matrix_xSym)),                 REAL(GET_SLOT(x, Matrix_xSym)),

Legend:
Removed from v.592  
changed lines
  Added in v.741

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