SCM

SCM Repository

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

Diff of /pkg/src/Csparse.c

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

revision 1371, Mon Aug 14 21:08:58 2006 UTC revision 1448, Sat Aug 26 03:29:36 2006 UTC
# Line 73  Line 73 
73    
74      Free(chxs);      Free(chxs);
75      if (asLogical(tri)) {       /* triangular sparse matrices */      if (asLogical(tri)) {       /* triangular sparse matrices */
76          uploT = (strcmp(CHAR(asChar(GET_SLOT(x, Matrix_uploSym))), "U")) ?          uploT = (*uplo_P(x) == 'U') ? -1 : 1;
77              -1 : 1;          diag = diag_P(x);
         diag = CHAR(asChar(GET_SLOT(x, Matrix_diagSym)));  
78      }      }
79      return chm_triplet_to_SEXP(chxt, 1, uploT, diag,      return chm_triplet_to_SEXP(chxt, 1, uploT, diag,
80                                 GET_SLOT(x, Matrix_DimNamesSym));                                 GET_SLOT(x, Matrix_DimNamesSym));
81  }  }
82    
83    /* this used to be called  sCMatrix_to_gCMatrix(..)   [in ./dsCMatrix.c ]: */
84  SEXP Csparse_symmetric_to_general(SEXP x)  SEXP Csparse_symmetric_to_general(SEXP x)
85  {  {
86      cholmod_sparse *chx = as_cholmod_sparse(x), *chgx;      cholmod_sparse *chx = as_cholmod_sparse(x), *chgx;
87    
88      if (!(chx->stype))      if (!(chx->stype))
89          error(_("Nonsymmetric matrix in Csparse_symmeteric_to_general"));          error(_("Nonsymmetric matrix in Csparse_symmeteric_to_general"));
90      chgx = cholmod_copy(chx, 0, chx->xtype, &c);      chgx = cholmod_copy(chx, /* stype: */ 0, chx->xtype, &c);
91        /* xtype: pattern, "real", complex or .. */
92      Free(chx);      Free(chx);
93      return chm_sparse_to_SEXP(chgx, 1, 0, "",      return chm_sparse_to_SEXP(chgx, 1, 0, "",
94                                GET_SLOT(x, Matrix_DimNamesSym));                                GET_SLOT(x, Matrix_DimNamesSym));
# Line 106  Line 107 
107      SET_VECTOR_ELT(dn, 1, tmp);      SET_VECTOR_ELT(dn, 1, tmp);
108      UNPROTECT(1);      UNPROTECT(1);
109      if (asLogical(tri)) {       /* triangular sparse matrices */      if (asLogical(tri)) {       /* triangular sparse matrices */
110          uploT = (strcmp(CHAR(asChar(GET_SLOT(x, Matrix_uploSym))), "U")) ?          uploT = (*uplo_P(x) == 'U') ? -1 : 1;
111              1 : -1;             /* switch upper and lower for transpose */          diag = diag_P(x);
         diag = CHAR(asChar(GET_SLOT(x, Matrix_diagSym)));  
112      }      }
113      return chm_sparse_to_SEXP(chxt, 1, uploT, diag, dn);      return chm_sparse_to_SEXP(chxt, 1, uploT, diag, dn);
114  }  }
# Line 132  Line 132 
132  {  {
133      cholmod_sparse *cha = as_cholmod_sparse(a);      cholmod_sparse *cha = as_cholmod_sparse(a);
134      cholmod_dense *chb = as_cholmod_dense(b);      cholmod_dense *chb = as_cholmod_dense(b);
135      cholmod_dense *chc = cholmod_allocate_dense(cha->nrow, chb->ncol,      cholmod_dense *chc =
136                                                  cha->nrow, chb->xtype, &c);          cholmod_allocate_dense(cha->nrow, chb->ncol, cha->nrow, chb->xtype, &c);
137      double alpha = 1, beta = 0;      double alpha[] = {1,0}, beta[] = {0,0};
138    
139      cholmod_sdmult(cha, 0, &alpha, &beta, chb, chc, &c);      cholmod_sdmult(cha, 0, alpha, beta, chb, chc, &c);
140      Free(cha); Free(chb);      Free(cha); Free(chb);
141      return chm_dense_to_SEXP(chc, 1);      return chm_dense_to_SEXP(chc, 1);
142  }  }
# Line 145  Line 145 
145  {  {
146      cholmod_sparse *cha = as_cholmod_sparse(a);      cholmod_sparse *cha = as_cholmod_sparse(a);
147      cholmod_dense *chb = as_cholmod_dense(b);      cholmod_dense *chb = as_cholmod_dense(b);
148      cholmod_dense *chc = cholmod_allocate_dense(cha->ncol, chb->ncol,      cholmod_dense *chc =
149                                                  cha->ncol, chb->xtype, &c);          cholmod_allocate_dense(cha->ncol, chb->ncol, cha->ncol, chb->xtype, &c);
150      double alpha = 1, beta = 0;      double alpha[] = {1,0}, beta[] = {0,0};
151    
152      cholmod_sdmult(cha, 1, &alpha, &beta, chb, chc, &c);      cholmod_sdmult(cha, 1, alpha, beta, chb, chc, &c);
153      Free(cha); Free(chb);      Free(cha); Free(chb);
154      return chm_dense_to_SEXP(chc, 1);      return chm_dense_to_SEXP(chc, 1);
155  }  }

Legend:
Removed from v.1371  
changed lines
  Added in v.1448

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