SCM

SCM Repository

[matrix] Diff of /pkg/R/sparseMatrix.R
ViewVC logotype

Diff of /pkg/R/sparseMatrix.R

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

revision 1471, Fri Sep 1 15:21:02 2006 UTC revision 1472, Fri Sep 1 15:31:04 2006 UTC
# Line 3  Line 3 
3  ### Idea: Coercion between *VIRTUAL* classes -- as() chooses "closest" classes  ### Idea: Coercion between *VIRTUAL* classes -- as() chooses "closest" classes
4  ### ----  should also work e.g. for  dense-triangular --> sparse-triangular !  ### ----  should also work e.g. for  dense-triangular --> sparse-triangular !
5    
6  ##-> see  ./dMatrix.R  and  ./lMatrix.R  ##-> see als ./dMatrix.R, ./ddenseMatrix.R  and  ./lMatrix.R
7    
8    setAs("ANY", "sparseMatrix", function(from) as(from, "CsparseMatrix"))
9    
10    
11  ## "graph" coercions -- this needs the graph package which is currently  ## "graph" coercions -- this needs the graph package which is currently
# Line 194  Line 196 
196  setMethod("-", signature(e1 = "pMatrix", e2 = "missing"),  setMethod("-", signature(e1 = "pMatrix", e2 = "missing"),
197            function(e1) callGeneric(as(e1, "lgTMatrix")))            function(e1) callGeneric(as(e1, "lgTMatrix")))
198    
199    ## Group method  "Arith"
200    
201    ## have CsparseMatrix methods (-> ./Csparse.R )
202    ## which may preserve "symmetric", "triangular" -- simply defer to those:
203    
204    setMethod("Arith", ##  "+", "-", "*", "^", "%%", "%/%", "/"
205              signature(e1 = "sparseMatrix", e2 = "sparseMatrix"),
206              function(e1, e2) callGeneric(as(e1, "CsparseMatrix"),
207                                           as(e2, "CsparseMatrix")))
208    setMethod("Arith",
209              signature(e1 = "sparseMatrix", e2 = "numeric"),
210              function(e1, e2) callGeneric(as(e1, "CsparseMatrix"), e2))
211    setMethod("Arith",
212              signature(e1 = "numeric", e2 = "sparseMatrix"),
213              function(e1, e2) callGeneric(e1, as(e2, "CsparseMatrix")))
214    
215    setMethod("Math",
216              signature(x = "sparseMatrix"),
217              function(x) callGeneric(as(x, "CsparseMatrix")))
218    
219    
220    
221  ### --- show() method ---  ### --- show() method ---
222    
223  ## FIXME(?) -- ``merge this'' (at least ``synchronize'') with  ## FIXME(?) -- ``merge this'' (at least ``synchronize'') with
# Line 287  Line 311 
311            })            })
312    
313    
314    setMethod("diag", signature(x = "sparseMatrix"),
315              function(x, nrow, ncol = n) diag(as(x, "CsparseMatrix")))
316    
317  ## .as.dgT.Fun  ## .as.dgT.Fun
318  setMethod("colSums",  signature(x = "sparseMatrix"), .as.dgT.Fun)  setMethod("colSums",  signature(x = "sparseMatrix"), .as.dgT.Fun)
319  setMethod("colMeans", signature(x = "sparseMatrix"), .as.dgT.Fun)  setMethod("colMeans", signature(x = "sparseMatrix"), .as.dgT.Fun)

Legend:
Removed from v.1471  
changed lines
  Added in v.1472

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