SCM

SCM Repository

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

Diff of /pkg/R/Ops.R

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

revision 2184, Sat Apr 26 20:32:39 2008 UTC revision 2185, Sat Apr 26 20:33:16 2008 UTC
# Line 238  Line 238 
238  setMethod("Compare", signature(e1 = "nMatrix", e2 = "nMatrix"), Ops.x.x)  setMethod("Compare", signature(e1 = "nMatrix", e2 = "nMatrix"), Ops.x.x)
239    
240  ## l o d : depends on *kind* of Ops -- but Ops.x.x works on slots - correctly:  ## l o d : depends on *kind* of Ops -- but Ops.x.x works on slots - correctly:
241  setMethod("Ops", signature(e1="lMatrix", e2="dMatrix"), Ops.x.x)  setMethod("Ops", signature(e1="lMatrix", e2="dMatrix"),
242              Ops.x.x)
243  setMethod("Ops", signature(e1="dMatrix", e2="lMatrix"), Ops.x.x)  setMethod("Ops", signature(e1="dMatrix", e2="lMatrix"), Ops.x.x)
244    
245    ## lMatrix & nMatrix ... probably should also just use "Matrix" ?
246    setMethod("Ops", signature(e1="lMatrix", e2="numeric"),
247              function(e1,e2) callGeneric(as(e1,"dMatrix"), e2))
248    setMethod("Ops", signature(e1="numeric", e2="lMatrix"),
249              function(e1,e2) callGeneric(e1, as(e2,"dMatrix")))
250    setMethod("Ops", signature(e1="nMatrix", e2="numeric"),
251              function(e1,e2) callGeneric(as(e1,"dMatrix"), e2))
252    setMethod("Ops", signature(e1="numeric", e2="nMatrix"),
253              function(e1,e2) callGeneric(e1, as(e2,"dMatrix")))
254    
255    setMethod("Ops", signature(e1="Matrix", e2="logical"),
256              function(e1,e2) callGeneric(as(e1,"lMatrix"), e2))
257    setMethod("Ops", signature(e1="logical", e2="Matrix"),
258              function(e1,e2) callGeneric(e1, as(e2,"lMatrix")))
259    
260  ### --  I -- dense -----------------------------------------------------------  ### --  I -- dense -----------------------------------------------------------
261    
# Line 561  Line 576 
576  setMethod("Arith", signature(e1="lgTMatrix", e2="lgTMatrix"),  setMethod("Arith", signature(e1="lgTMatrix", e2="lgTMatrix"),
577            function(e1, e2) callGeneric(as(e1, "dgTMatrix"), as(e2, "dgTMatrix")))            function(e1, e2) callGeneric(as(e1, "dgTMatrix"), as(e2, "dgTMatrix")))
578    
579    ## More generally:  Arith: l* and n*  via  d*
580    setMethod("Arith", signature(e1="lsparseMatrix", e2="Matrix"),
581              function(e1, e2) callGeneric(as(e1, "dMatrix"), as(e2,"dMatrix")))
582    setMethod("Arith", signature(e1="Matrix", e2="lsparseMatrix"),
583              function(e1, e2) callGeneric(as(e1, "dMatrix"), as(e2,"dMatrix")))
584    setMethod("Arith", signature(e1="nsparseMatrix", e2="Matrix"),
585              function(e1, e2) callGeneric(as(e1, "dMatrix"), as(e2,"dMatrix")))
586    setMethod("Arith", signature(e1="Matrix", e2="nsparseMatrix"),
587              function(e1, e2) callGeneric(as(e1, "dMatrix"), as(e2,"dMatrix")))
588    ##
589    setMethod("Arith", signature(e1="lMatrix", e2="numeric"),
590              function(e1, e2) callGeneric(as(e1, "dMatrix"), e2))
591    setMethod("Arith", signature(e1="numeric", e2="lMatrix"),
592              function(e1, e2) callGeneric(e1, as(e2,"dMatrix")))
593    setMethod("Arith", signature(e1="nMatrix", e2="numeric"),
594              function(e1, e2) callGeneric(as(e1, "dMatrix"), e2))
595    setMethod("Arith", signature(e1="numeric", e2="nMatrix"),
596              function(e1, e2) callGeneric(e1, as(e2,"dMatrix")))
597    
598    
599  ## FIXME: These are really too cheap: currently almost all go via dgC*() :  ## FIXME: These are really too cheap: currently almost all go via dgC*() :
600  ## setMethod("Compare", signature(e1="lgCMatrix", e2="lgCMatrix"),  ## setMethod("Compare", signature(e1="lgCMatrix", e2="lgCMatrix"),
601  ## setMethod("Compare", signature(e1="lgTMatrix", e2="lgTMatrix"),  ## setMethod("Compare", signature(e1="lgTMatrix", e2="lgTMatrix"),
# Line 796  Line 831 
831                    }                    }
832                }                }
833                ## all other (potentially non-sparse) cases: give up symm, tri,..                ## all other (potentially non-sparse) cases: give up symm, tri,..
834                callGeneric(as(e1, paste(.M.kind(e1), "gCMatrix", sep='')), e2)                callGeneric(as(as(e1, "dMatrix"), "dgCMatrix"), e2)
835            })            })
836    
837  ## The same,  e1 <-> e2 :  ## The same,  e1 <-> e2 :
# Line 810  Line 845 
845                        return(e2)                        return(e2)
846                    }                    }
847                }                }
848                callGeneric(e1, as(e2, paste(.M.kind(e2), "gCMatrix", sep='')))                callGeneric(e1, as(as(e2, "dMatrix"), "dgCMatrix"))
849            })            })
850    
851    
852  setMethod("Compare", signature(e1 = "CsparseMatrix", e2 = "CsparseMatrix"),  setMethod("Compare", signature(e1 = "CsparseMatrix", e2 = "CsparseMatrix"),
853            function(e1, e2) {            function(e1, e2) {
854                d <- dimCheck(e1,e2)                d <- dimCheck(e1,e2)

Legend:
Removed from v.2184  
changed lines
  Added in v.2185

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