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 923, Sun Sep 18 23:41:45 2005 UTC revision 1029, Wed Nov 9 15:26:22 2005 UTC
# Line 37  Line 37 
37      cholmod_sparse *chxs = as_cholmod_sparse(x);      cholmod_sparse *chxs = as_cholmod_sparse(x);
38      cholmod_triplet *chxt = cholmod_sparse_to_triplet(chxs, &c);      cholmod_triplet *chxt = cholmod_sparse_to_triplet(chxs, &c);
39    
40      Free(chxs);      free(chxs);
41      return chm_triplet_to_SEXP(chxt, 1);      return chm_triplet_to_SEXP(chxt, 1);
42  #else  #else
43      error("General conversion requires CHOLMOD");      error("General conversion requires CHOLMOD");
# Line 51  Line 51 
51      cholmod_sparse *chx = as_cholmod_sparse(x);      cholmod_sparse *chx = as_cholmod_sparse(x);
52      cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c);      cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c);
53    
54      Free(chx);      free(chx);
55      return chm_sparse_to_SEXP(chxt, 1);      return chm_sparse_to_SEXP(chxt, 1);
56  #else  #else
57      error("General conversion requires CHOLMOD");      error("General conversion requires CHOLMOD");
# Line 66  Line 66 
66      cholmod_sparse *cha = as_cholmod_sparse(a), *chb = as_cholmod_sparse(b);      cholmod_sparse *cha = as_cholmod_sparse(a), *chb = as_cholmod_sparse(b);
67      cholmod_sparse *chc = cholmod_ssmult(cha, chb, 0, (int) cha->xtype, 1, &c);      cholmod_sparse *chc = cholmod_ssmult(cha, chb, 0, (int) cha->xtype, 1, &c);
68    
69      Free(cha); Free(chb);      free(cha); free(chb);
70      return chm_sparse_to_SEXP(chc, 1);      return chm_sparse_to_SEXP(chc, 1);
71  #else  #else
72      error("General multiplication requires CHOLMOD");      error("General multiplication requires CHOLMOD");
# Line 84  Line 84 
84      double alpha = 1, beta = 0;      double alpha = 1, beta = 0;
85    
86      cholmod_sdmult(cha, 0, &alpha, &beta, chb, chc, &c);      cholmod_sdmult(cha, 0, &alpha, &beta, chb, chc, &c);
87      Free(cha); Free(chb);      free(cha); free(chb);
88      return chm_dense_to_SEXP(chc, 1);      return chm_dense_to_SEXP(chc, 1);
89  #else  #else
90      error("General multiplication requires CHOLMOD");      error("General multiplication requires CHOLMOD");
# Line 92  Line 92 
92  #endif  /* USE_CHOLMOD */  #endif  /* USE_CHOLMOD */
93  }  }
94    
95  SEXP Csparse_crossprod(SEXP x, SEXP trans)  SEXP Csparse_crossprod(SEXP x, SEXP trans, SEXP triplet)
96  {  {
97  #ifdef USE_CHOLMOD  #ifdef USE_CHOLMOD
98      int tr = asLogical(trans);  /* gets reversed because _aat is trcrossprod */      int trip = asLogical(triplet),
99      cholmod_sparse *chx = as_cholmod_sparse(x), *chcp, *chxt;          tr   = asLogical(trans); /* gets reversed because _aat is tcrossprod */
100        cholmod_triplet
101            *cht = trip ? as_cholmod_triplet(x) : (cholmod_triplet*) NULL;
102        cholmod_sparse *chcp, *chxt,
103            *chx = trip ? cholmod_triplet_to_sparse(cht, cht->nnz, &c)
104            : as_cholmod_sparse(x);
105    
106      if (!tr)      if (!tr)
107          chxt = cholmod_transpose(chx, (int) chx->xtype, &c);          chxt = cholmod_transpose(chx, (int) chx->xtype, &c);
108      chcp = cholmod_aat((tr) ? chxt : chx, (int *) NULL, 0, chx->xtype, &c);      chcp = cholmod_aat((!tr) ? chxt : chx, (int *) NULL, 0, chx->xtype, &c);
109        if(!chcp)
110      Free(chx);          error("Csparse_crossprod(): error return from cholmod_aat()");
111    
112        if (trip) {
113            cholmod_free_sparse(&chx, &c);
114            free(cht);
115        } else {
116            free(chx);
117        }
118      if (!tr) cholmod_free_sparse(&chxt, &c);      if (!tr) cholmod_free_sparse(&chxt, &c);
119      return chm_sparse_to_SEXP(chcp, 1);      return chm_sparse_to_SEXP(chcp, 1);
120  #else  #else
121      error("General transpose requires CHOLMOD");      error("General crossproduct requires CHOLMOD");
122      return R_NilValue;          /* -Wall */      return R_NilValue;          /* -Wall */
123  #endif  /* USE_CHOLMOD */  #endif  /* USE_CHOLMOD */
124  }  }

Legend:
Removed from v.923  
changed lines
  Added in v.1029

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