SCM

SCM Repository

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

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

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

revision 1866, Mon Jun 4 17:11:11 2007 UTC revision 1867, Mon Jun 4 17:13:02 2007 UTC
# Line 61  Line 61 
61      cholmod_sparse *chxs = as_cholmod_sparse(x);      cholmod_sparse *chxs = as_cholmod_sparse(x);
62      cholmod_sparse      cholmod_sparse
63          *chxcp = cholmod_copy(chxs, chxs->stype, CHOLMOD_PATTERN, &c);          *chxcp = cholmod_copy(chxs, chxs->stype, CHOLMOD_PATTERN, &c);
64      int uploT = 0; char *diag = "";      int tr = asLogical(tri);
65    
66      Free(chxs);      Free(chxs);
67      if (asLogical(tri)) {       /* triangular sparse matrices */      return chm_sparse_to_SEXP(chxcp, 1,
68          uploT = (*uplo_P(x) == 'U') ? 1 : -1;                                tr ? ((*uplo_P(x) == 'U') ? 1 : -1) : 0,
69          diag = CHAR(asChar(GET_SLOT(x, Matrix_diagSym)));                                0, tr ? diag_P(x) : "",
     }  
     return chm_sparse_to_SEXP(chxcp, 1, uploT, 0, diag,  
70                                GET_SLOT(x, Matrix_DimNamesSym));                                GET_SLOT(x, Matrix_DimNamesSym));
71  }  }
72    
# Line 86  Line 84 
84  {  {
85      cholmod_sparse *chxs = as_cholmod_sparse(x);      cholmod_sparse *chxs = as_cholmod_sparse(x);
86      cholmod_triplet *chxt = cholmod_sparse_to_triplet(chxs, &c);      cholmod_triplet *chxt = cholmod_sparse_to_triplet(chxs, &c);
87      int uploT = 0;      int tr = asLogical(tri);
     char *diag = "";  
88      int Rkind = (chxs->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0;      int Rkind = (chxs->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0;
89    
90      Free(chxs);      Free(chxs);
91      if (asLogical(tri)) {       /* triangular sparse matrices */      return chm_triplet_to_SEXP(chxt, 1,
92          uploT = (*uplo_P(x) == 'U') ? 1 : -1;                                 tr ? ((*uplo_P(x) == 'U') ? 1 : -1) : 0,
93          diag = diag_P(x);                                 Rkind, tr ? diag_P(x) : "",
     }  
     return chm_triplet_to_SEXP(chxt, 1, uploT, Rkind, diag,  
94                                 GET_SLOT(x, Matrix_DimNamesSym));                                 GET_SLOT(x, Matrix_DimNamesSym));
95  }  }
96    
# Line 133  Line 128 
128      int Rkind = (chx->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0;      int Rkind = (chx->xtype != CHOLMOD_PATTERN) ? Real_kind(x) : 0;
129      cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c);      cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c);
130      SEXP dn = PROTECT(duplicate(GET_SLOT(x, Matrix_DimNamesSym))), tmp;      SEXP dn = PROTECT(duplicate(GET_SLOT(x, Matrix_DimNamesSym))), tmp;
131      int uploT = 0; char *diag = "";      int tr = asLogical(tri);
132    
133      Free(chx);      Free(chx);
134      tmp = VECTOR_ELT(dn, 0);    /* swap the dimnames */      tmp = VECTOR_ELT(dn, 0);    /* swap the dimnames */
135      SET_VECTOR_ELT(dn, 0, VECTOR_ELT(dn, 1));      SET_VECTOR_ELT(dn, 0, VECTOR_ELT(dn, 1));
136      SET_VECTOR_ELT(dn, 1, tmp);      SET_VECTOR_ELT(dn, 1, tmp);
137      UNPROTECT(1);      UNPROTECT(1);
138      if (asLogical(tri)) { /* triangular sparse matrices : SWAP 'uplo' */      return chm_sparse_to_SEXP(chxt, 1, /* SWAP 'uplo' for triangular */
139          uploT = (*uplo_P(x) == 'U') ? -1 : 1;                                tr ? ((*uplo_P(x) == 'U') ? -1 : 1) : 0,
140          diag = diag_P(x);                                Rkind, tr ? diag_P(x) : "", dn);
     }  
     return chm_sparse_to_SEXP(chxt, 1, uploT, Rkind, diag, dn);  
141  }  }
142    
143  SEXP Csparse_Csparse_prod(SEXP a, SEXP b)  SEXP Csparse_Csparse_prod(SEXP a, SEXP b)

Legend:
Removed from v.1866  
changed lines
  Added in v.1867

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