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 928, Mon Sep 19 21:10:59 2005 UTC revision 957, Sat Oct 1 20:08:04 2005 UTC
# Line 95  Line 95 
95  SEXP Csparse_crossprod(SEXP x, SEXP trans, SEXP triplet)  SEXP Csparse_crossprod(SEXP x, SEXP trans, SEXP triplet)
96  {  {
97  #ifdef USE_CHOLMOD  #ifdef USE_CHOLMOD
98      int trip = asLogical(triplet);      int trip = asLogical(triplet),
99            tr   = asLogical(trans); /* gets reversed because _aat is tcrossprod */
100      cholmod_triplet      cholmod_triplet
101          *cht = trip ? as_cholmod_triplet(x) : (cholmod_triplet*) NULL;          *cht = trip ? as_cholmod_triplet(x) : (cholmod_triplet*) NULL;
102      cholmod_sparse *chcp, *chxt,      cholmod_sparse *chcp, *chxt,
103          *chx = trip ? cholmod_triplet_to_sparse(cht, cht->nnz, &c)          *chx = trip ? cholmod_triplet_to_sparse(cht, cht->nnz, &c)
104          : as_cholmod_sparse(x);          : as_cholmod_sparse(x);
     int tr = asLogical(trans);  /* gets reversed because _aat is tcrossprod */  
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            error("Csparse_crossprod(): error return from cholmod_aat()");
111    
112      Free(trip ? cht : chx);      if (trip) {
113      if (trip) cholmod_free_sparse(&chx, &c);          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.928  
changed lines
  Added in v.957

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