SCM

SCM Repository

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

Diff of /pkg/Matrix/src/dtCMatrix.c

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

revision 582, Mon Feb 28 18:15:21 2005 UTC revision 945, Wed Sep 28 08:54:28 2005 UTC
# Line 1  Line 1 
1                                  /* Sparse triangular matrices */                                  /* Sparse triangular numeric matrices */
2  #include "dtCMatrix.h"  #include "dtCMatrix.h"
3    
4  SEXP tsc_validate(SEXP x)  SEXP tsc_validate(SEXP x)
5  {  {
6      return ScalarLogical(1);      return triangularMatrix_validate(x);
7        /* see ./dsCMatrix.c or ./dtpMatrix.c  on how to do more testing here */
8  }  }
9    
10  SEXP tsc_transpose(SEXP x)  SEXP tsc_transpose(SEXP x)
11  {  {
12      SEXP      SEXP ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dtCMatrix"))),
         ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dtCMatrix"))),  
13          islot = GET_SLOT(x, Matrix_iSym);          islot = GET_SLOT(x, Matrix_iSym);
14      int nnz = length(islot),      int nnz = length(islot),
15          *adims, *xdims = INTEGER(GET_SLOT(x, Matrix_DimSym));          *adims, *xdims = INTEGER(GET_SLOT(x, Matrix_DimSym));
16        int up = CHAR(asChar(GET_SLOT(x, Matrix_uploSym)))[0] == 'U';
17    
18        adims = INTEGER(ALLOC_SLOT(ans, Matrix_DimSym, INTSXP, 2));
     SET_SLOT(ans, Matrix_DimSym, allocVector(INTSXP, 2));  
     adims = INTEGER(GET_SLOT(ans, Matrix_DimSym));  
19      adims[0] = xdims[1]; adims[1] = xdims[0];      adims[0] = xdims[1]; adims[1] = xdims[0];
20      if (CHAR(asChar(GET_SLOT(x, Matrix_uploSym)))[0] == 'U')  
21          SET_SLOT(ans, Matrix_uploSym, mkString("L"));      if(diag_value(x) == 'U')
22      SET_SLOT(ans, Matrix_pSym, allocVector(INTSXP, xdims[0] + 1));          SET_SLOT(ans, Matrix_diagSym, duplicate(GET_SLOT(x, Matrix_diagSym)));
23      SET_SLOT(ans, Matrix_iSym, allocVector(INTSXP, nnz));      SET_SLOT(ans, Matrix_uploSym, mkString(up ? "L" : "U"));
24      SET_SLOT(ans, Matrix_xSym, allocVector(REALSXP, nnz));  
25      csc_components_transpose(xdims[0], xdims[1], nnz,      csc_compTr(xdims[0], xdims[1], nnz,
26                               INTEGER(GET_SLOT(x, Matrix_pSym)),                 INTEGER(GET_SLOT(x, Matrix_pSym)), INTEGER(islot),
                              INTEGER(islot),  
27                               REAL(GET_SLOT(x, Matrix_xSym)),                               REAL(GET_SLOT(x, Matrix_xSym)),
28                               INTEGER(GET_SLOT(ans, Matrix_pSym)),                 INTEGER(ALLOC_SLOT(ans, Matrix_pSym, INTSXP, xdims[0] + 1)),
29                               INTEGER(GET_SLOT(ans, Matrix_iSym)),                 INTEGER(ALLOC_SLOT(ans, Matrix_iSym, INTSXP, nnz)),
30                               REAL(GET_SLOT(ans, Matrix_xSym)));                 REAL(ALLOC_SLOT(ans, Matrix_xSym, REALSXP, nnz)));
31      UNPROTECT(1);      UNPROTECT(1);
32      return ans;      return ans;
33  }  }
# Line 38  Line 36 
36  {  {
37      SEXP ans;      SEXP ans;
38      if (CHAR(STRING_ELT(GET_SLOT(x, Matrix_diagSym), 0))[0] != 'U')      if (CHAR(STRING_ELT(GET_SLOT(x, Matrix_diagSym), 0))[0] != 'U')
39          ans = csc_to_dgTMatrix(x);          ans = compressed_to_dgTMatrix(x, ScalarLogical(1));
40      else {                      /* unit triangular matrix */      else {                      /* unit triangular matrix */
41          SEXP islot = GET_SLOT(x, Matrix_iSym),          SEXP islot = GET_SLOT(x, Matrix_iSym),
42              pslot = GET_SLOT(x, Matrix_pSym);              pslot = GET_SLOT(x, Matrix_pSym);

Legend:
Removed from v.582  
changed lines
  Added in v.945

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