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 1067, Mon Nov 28 16:27:29 2005 UTC revision 1360, Tue Aug 8 17:29:03 2006 UTC
# Line 1  Line 1 
1                          /* Sparse matrices in compress column-oriented form */                          /* Sparse matrices in compressed column-oriented form */
2  #include "Csparse.h"  #include "Csparse.h"
3  #include "chm_common.h"  #include "chm_common.h"
4    
# Line 34  Line 34 
34      cholmod_sparse *chxs = as_cholmod_sparse(x);      cholmod_sparse *chxs = as_cholmod_sparse(x);
35      cholmod_dense *chxd = cholmod_sparse_to_dense(chxs, &c);      cholmod_dense *chxd = cholmod_sparse_to_dense(chxs, &c);
36    
37      free(chxs);      Free(chxs);
38      return chm_dense_to_SEXP(chxd, 1);      return chm_dense_to_SEXP(chxd, 1);
39  }  }
40    
# Line 43  Line 43 
43      cholmod_sparse *chxs = as_cholmod_sparse(x);      cholmod_sparse *chxs = as_cholmod_sparse(x);
44      cholmod_triplet *chxt = cholmod_sparse_to_triplet(chxs, &c);      cholmod_triplet *chxt = cholmod_sparse_to_triplet(chxs, &c);
45    
46      free(chxs);      Free(chxs);
47      return chm_triplet_to_SEXP(chxt, 1);      return chm_triplet_to_SEXP(chxt, 1);
48  }  }
49    
# Line 52  Line 52 
52      cholmod_sparse *chx = as_cholmod_sparse(x);      cholmod_sparse *chx = as_cholmod_sparse(x);
53      cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c);      cholmod_sparse *chxt = cholmod_transpose(chx, (int) chx->xtype, &c);
54    
55      free(chx);      Free(chx);
56      return chm_sparse_to_SEXP(chxt, 1);      return chm_sparse_to_SEXP(chxt, 1);
57  }  }
58    
# Line 62  Line 62 
62          *chb = as_cholmod_sparse(b);          *chb = as_cholmod_sparse(b);
63      cholmod_sparse *chc = cholmod_ssmult(cha, chb, 0, cha->xtype, 1, &c);      cholmod_sparse *chc = cholmod_ssmult(cha, chb, 0, cha->xtype, 1, &c);
64    
65      free(cha); free(chb);      Free(cha); Free(chb);
66      return chm_sparse_to_SEXP(chc, 1);      return chm_sparse_to_SEXP(chc, 1);
67  }  }
68    
# Line 75  Line 75 
75      double alpha = 1, beta = 0;      double alpha = 1, beta = 0;
76    
77      cholmod_sdmult(cha, 0, &alpha, &beta, chb, chc, &c);      cholmod_sdmult(cha, 0, &alpha, &beta, chb, chc, &c);
78      free(cha); free(chb);      Free(cha); Free(chb);
79      return chm_dense_to_SEXP(chc, 1);      return chm_dense_to_SEXP(chc, 1);
80  }  }
81    
# Line 103  Line 103 
103          : as_cholmod_sparse(x);          : as_cholmod_sparse(x);
104    
105      if (!tr)      if (!tr)
106          chxt = cholmod_transpose(chx, (int) chx->xtype, &c);          chxt = cholmod_transpose(chx, chx->xtype, &c);
107      chcp = cholmod_aat((!tr) ? chxt : chx, (int *) NULL, 0, chx->xtype, &c);      chcp = cholmod_aat((!tr) ? chxt : chx, (int *) NULL, 0, chx->xtype, &c);
108      if(!chcp)      if(!chcp)
109          error("Csparse_crossprod(): error return from cholmod_aat()");          error("Csparse_crossprod(): error return from cholmod_aat()");
110        cholmod_band_inplace(0, chcp->ncol, chcp->xtype, chcp, &c);
111        chcp->stype = 1;
112      if (trip) {      if (trip) {
113          cholmod_free_sparse(&chx, &c);          cholmod_free_sparse(&chx, &c);
114          free(cht);          Free(cht);
115      } else {      } else {
116          free(chx);          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  }  }
121    
122    SEXP Csparse_horzcat(SEXP x, SEXP y)
123    {
124        cholmod_sparse *chx = as_cholmod_sparse(x),
125            *chy = as_cholmod_sparse(y), *ans;
126    
127        ans = cholmod_horzcat(chx, chy, 1, &c);
128        Free(chx); Free(chy);
129        return chm_sparse_to_SEXP(ans, 1);
130    }
131    
132    SEXP Csparse_vertcat(SEXP x, SEXP y)
133    {
134        cholmod_sparse *chx = as_cholmod_sparse(x),
135            *chy = as_cholmod_sparse(y), *ans;
136    
137        ans = cholmod_vertcat(chx, chy, 1, &c);
138        Free(chx); Free(chy);
139        return chm_sparse_to_SEXP(ans, 1);
140    }
141    
142    SEXP Csparse_band(SEXP x, SEXP k1, SEXP k2)
143    {
144        cholmod_sparse *chx = as_cholmod_sparse(x), *ans;
145    
146        ans = cholmod_band(chx, asInteger(k1), asInteger(k2), chx->xtype, &c);
147        Free(chx);
148        return chm_sparse_to_SEXP(ans, 1);
149    }

Legend:
Removed from v.1067  
changed lines
  Added in v.1360

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