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 922, Sun Sep 18 16:33:54 2005 UTC revision 930, Mon Sep 19 21:29:37 2005 UTC
# Line 85  Line 85 
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_sparse_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");
91      return R_NilValue;          /* -Wall */      return R_NilValue;          /* -Wall */
92  #endif  /* USE_CHOLMOD */  #endif  /* USE_CHOLMOD */
93  }  }
94    
95  SEXP Csparse_tcrossprod(SEXP x)  SEXP Csparse_crossprod(SEXP x, SEXP trans, SEXP triplet)
96  {  {
97  #ifdef USE_CHOLMOD  #ifdef USE_CHOLMOD
98      cholmod_sparse *chx = as_cholmod_sparse(x);      int trip = asLogical(triplet);
99      cholmod_sparse *chxt = cholmod_aat(chx, (int *) NULL, 0, chx->xtype, &c);      cholmod_triplet
100            *cht = trip ? as_cholmod_triplet(x) : (cholmod_triplet*) NULL;
101        cholmod_sparse *chcp, *chxt,
102            *chx = trip ? cholmod_triplet_to_sparse(cht, cht->nnz, &c)
103            : as_cholmod_sparse(x);
104        int tr = asLogical(trans);  /* gets reversed because _aat is tcrossprod */
105    
106        if (!tr)
107            chxt = cholmod_transpose(chx, (int) chx->xtype, &c);
108        chcp = cholmod_aat((!tr) ? chxt : chx, (int *) NULL, 0, chx->xtype, &c);
109    
110        if (trip) {
111            cholmod_free_sparse(&chx, &c);
112            Free(cht);
113        } else {
114      Free(chx);      Free(chx);
115      return chm_sparse_to_SEXP(chxt, 1);      }
116        if (!tr) cholmod_free_sparse(&chxt, &c);
117        return chm_sparse_to_SEXP(chcp, 1);
118  #else  #else
119      error("General transpose requires CHOLMOD");      error("General crossproduct requires CHOLMOD");
120      return R_NilValue;          /* -Wall */      return R_NilValue;          /* -Wall */
121  #endif  /* USE_CHOLMOD */  #endif  /* USE_CHOLMOD */
122  }  }
123    

Legend:
Removed from v.922  
changed lines
  Added in v.930

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