SCM

SCM Repository

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

Diff of /pkg/src/geMatrix.c

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

revision 461, Sat Jan 29 14:09:38 2005 UTC revision 476, Wed Feb 2 11:51:24 2005 UTC
# Line 4  Line 4 
4  {  {
5      SEXP x = GET_SLOT(obj, Matrix_xSym),      SEXP x = GET_SLOT(obj, Matrix_xSym),
6          Dim = GET_SLOT(obj, Matrix_DimSym),          Dim = GET_SLOT(obj, Matrix_DimSym),
7          fact = GET_SLOT(obj, Matrix_factorization),          fact = GET_SLOT(obj, Matrix_factorSym),
8          rc = GET_SLOT(obj, Matrix_rcondSym);          rc = GET_SLOT(obj, Matrix_rcondSym);
9      int m, n;      int m, n;
10    
# Line 16  Line 16 
16      if (length(x) != m * n)      if (length(x) != m * n)
17          return ScalarString(mkChar("length of x slot != prod(Dim)"));          return ScalarString(mkChar("length of x slot != prod(Dim)"));
18      if (length(fact) > 0 && getAttrib(fact, R_NamesSymbol) == R_NilValue)      if (length(fact) > 0 && getAttrib(fact, R_NamesSymbol) == R_NilValue)
19          return ScalarString(mkChar("factorization slot must be named list"));          return ScalarString(mkChar("factors slot must be named list"));
20      if (length(rc) > 0 && getAttrib(rc, R_NamesSymbol) == R_NilValue)      if (length(rc) > 0 && getAttrib(rc, R_NamesSymbol) == R_NilValue)
21          return ScalarString(mkChar("rcond slot must be named numeric vector"));          return ScalarString(mkChar("rcond slot must be named numeric vector"));
22      return ScalarLogical(1);      return ScalarLogical(1);
# Line 83  Line 83 
83      int nsqr = n * n;      int nsqr = n * n;
84      double one = 1.0, *xvals, zero = 0.0;      double one = 1.0, *xvals, zero = 0.0;
85    
86      SET_SLOT(val, Matrix_factorization, allocVector(VECSXP, 0));      SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
87      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));
88      SET_SLOT(val, Matrix_uploSym, ScalarString(mkChar("U")));      SET_SLOT(val, Matrix_uploSym, ScalarString(mkChar("U")));
89      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));
# Line 109  Line 109 
109      double one = 1.0, zero = 0.0;      double one = 1.0, zero = 0.0;
110    
111      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));
112      SET_SLOT(val, Matrix_factorization, allocVector(VECSXP, 0));      SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
113      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));
114      vDims = INTEGER(GET_SLOT(val, Matrix_DimSym));      vDims = INTEGER(GET_SLOT(val, Matrix_DimSym));
115      if ((*xDims) > 0 && (*yDims) > 0 && n > 0 && m > 0) {      if ((*xDims) > 0 && (*yDims) > 0 && n > 0 && m > 0) {
# Line 139  Line 139 
139      if (!(isMatrix(y) && isReal(y)))      if (!(isMatrix(y) && isReal(y)))
140          error("Argument y must be a numeric (real) matrix");          error("Argument y must be a numeric (real) matrix");
141      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));
142      SET_SLOT(val, Matrix_factorization, allocVector(VECSXP, 0));      SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
143      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));
144      vDims = INTEGER(GET_SLOT(val, Matrix_DimSym));      vDims = INTEGER(GET_SLOT(val, Matrix_DimSym));
145      if ((*xDims) > 0 && (*yDims) > 0 && n > 0 && m > 0) {      if ((*xDims) > 0 && (*yDims) > 0 && n > 0 && m > 0) {
# Line 173  Line 173 
173    
174  SEXP geMatrix_LU(SEXP x)  SEXP geMatrix_LU(SEXP x)
175  {  {
176      SEXP val = get_factorization(x, "LU");      SEXP val = get_factors(x, "LU");
177      int *dims, npiv, info;      int *dims, npiv, info;
178    
179      if (val != R_NilValue) return val;      if (val != R_NilValue) return val;
# Line 190  Line 190 
190                       &info);                       &info);
191      if (info) error("Lapack routine dgetrf returned error code %d", info);      if (info) error("Lapack routine dgetrf returned error code %d", info);
192      UNPROTECT(1);      UNPROTECT(1);
193      return set_factorization(x, val, "LU");      return set_factors(x, val, "LU");
194  }  }
195    
196  SEXP geMatrix_determinant(SEXP x, SEXP logarithm)  SEXP geMatrix_determinant(SEXP x, SEXP logarithm)
# Line 236  Line 236 
236    
237      if (dims[0] != dims[1]) error("Solve requires a square matrix");      if (dims[0] != dims[1]) error("Solve requires a square matrix");
238      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));
239      SET_SLOT(val, Matrix_factorization, allocVector(VECSXP, 0));      SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
240      SET_SLOT(val, Matrix_xSym, duplicate(GET_SLOT(lu, Matrix_xSym)));      SET_SLOT(val, Matrix_xSym, duplicate(GET_SLOT(lu, Matrix_xSym)));
241      x = REAL(GET_SLOT(val, Matrix_xSym));      x = REAL(GET_SLOT(val, Matrix_xSym));
242      SET_SLOT(val, Matrix_DimSym, duplicate(GET_SLOT(lu, Matrix_DimSym)));      SET_SLOT(val, Matrix_DimSym, duplicate(GET_SLOT(lu, Matrix_DimSym)));
# Line 264  Line 264 
264      if (m < 1 || n < 1 || k < 1)      if (m < 1 || n < 1 || k < 1)
265          error("Matrices with zero extents cannot be multiplied");          error("Matrices with zero extents cannot be multiplied");
266      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));      SET_SLOT(val, Matrix_rcondSym, allocVector(REALSXP, 0));
267      SET_SLOT(val, Matrix_factorization, allocVector(VECSXP, 0));      SET_SLOT(val, Matrix_factorSym, allocVector(VECSXP, 0));
268      SET_SLOT(val, Matrix_xSym, allocVector(REALSXP, m * n));      SET_SLOT(val, Matrix_xSym, allocVector(REALSXP, m * n));
269      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));      SET_SLOT(val, Matrix_DimSym, allocVector(INTSXP, 2));
270      cdims = INTEGER(GET_SLOT(val, Matrix_DimSym));      cdims = INTEGER(GET_SLOT(val, Matrix_DimSym));

Legend:
Removed from v.461  
changed lines
  Added in v.476

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