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 682, Thu Mar 31 08:07:02 2005 UTC revision 683, Thu Mar 31 17:10:16 2005 UTC
# Line 89  Line 89 
89      return set_factors(xorig, val, "Cholesky");      return set_factors(xorig, val, "Cholesky");
90  }  }
91    
92  SEXP dsCMatrix_matrix_solve(SEXP a, SEXP b)  SEXP dsCMatrix_matrix_solve(SEXP a, SEXP b, SEXP classed)
93  {  {
94        int cl = asLogical(classed);
95      SEXP Chol = get_factors(a, "Cholesky"), perm,      SEXP Chol = get_factors(a, "Cholesky"), perm,
96          val = PROTECT(duplicate(b));          bdP = cl ? GET_SLOT(b, Matrix_DimSym) : getAttrib(b, R_DimSymbol),
97            val = PROTECT(NEW_OBJECT(MAKE_CLASS("dgeMatrix")));
98      int *adims = INTEGER(GET_SLOT(a, Matrix_DimSym)),      int *adims = INTEGER(GET_SLOT(a, Matrix_DimSym)),
99          *bdims = INTEGER(getAttrib(b, R_DimSymbol)),          *bdims = INTEGER(bdP), *Li, *Lp, j, piv;
100          *Li, *Lp, j, n = adims[1], ncol = bdims[1], piv;      int n = adims[1], ncol = bdims[1];
101      double *Lx, *D, *in = REAL(b), *out = REAL(val), *tmp = (double *) NULL;      double *Lx, *D, *in = REAL(cl ? GET_SLOT(b, Matrix_xSym) : b),
102            *out = REAL(ALLOC_SLOT(val, Matrix_xSym, REALSXP, n * ncol)),
103            *tmp = (double *) NULL;
104    
105      if (!(isReal(b) && isMatrix(b)))      if (!cl && !(isReal(b) && isMatrix(b)))
106          error(_("Argument b must be a numeric matrix"));          error(_("Argument b must be a numeric matrix"));
107      if (*adims != *bdims || bdims[1] < 1 || *adims < 1)      if (*adims != *bdims || ncol < 1 || *adims < 1)
108          error(_("Dimensions of system to be solved are inconsistent"));          error(_("Dimensions of system to be solved are inconsistent"));
109      if (Chol == R_NilValue) Chol = dsCMatrix_chol(a, ScalarLogical(1));      if (Chol == R_NilValue) Chol = dsCMatrix_chol(a, ScalarLogical(1));
110      perm = GET_SLOT(Chol, Matrix_permSym);      perm = GET_SLOT(Chol, Matrix_permSym);

Legend:
Removed from v.682  
changed lines
  Added in v.683

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