SCM

SCM Repository

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

Diff of /pkg/R/Matrix.R

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

revision 1330, Fri Jul 21 08:28:18 2006 UTC revision 1331, Sat Jul 22 17:59:53 2006 UTC
# Line 1  Line 1 
1  #### Toplevel ``virtual'' class "Matrix"  #### Toplevel ``virtual'' class "Matrix"
2    
3    
4    ### Virtual coercions -- via smart "helpers" (-> ./Auxiliaries.R)
5    
6    setAs("Matrix", "sparseMatrix", function(from) as_Csparse(from))
7    setAs("Matrix", "denseMatrix",  function(from) as_dense(from))
8    
9  ## ## probably not needed eventually:  ## ## probably not needed eventually:
10  ## setAs(from = "ddenseMatrix", to = "matrix",  ## setAs(from = "ddenseMatrix", to = "matrix",
11  ##       function(from) {  ##       function(from) {
# Line 188  Line 194 
194    
195  setMethod("crossprod", signature(x = "Matrix", y = "numeric"),  setMethod("crossprod", signature(x = "Matrix", y = "numeric"),
196            function(x, y = NULL) callGeneric(x, as.matrix(y)))            function(x, y = NULL) callGeneric(x, as.matrix(y)))
   
197  setMethod("crossprod", signature(x = "numeric", y = "Matrix"),  setMethod("crossprod", signature(x = "numeric", y = "Matrix"),
198            function(x, y = NULL)  callGeneric(rbind(x), y))            function(x, y = NULL)  callGeneric(as.matrix(x), y))
199    
200    ## The as.matrix() promotion seems illogical to MM,
201    ## but is according to help(tcrossprod, package = "base") :
202    setMethod("tcrossprod", signature(x = "Matrix", y = "numeric"),
203              function(x, y = NULL) callGeneric(x, as.matrix(y)))
204    setMethod("tcrossprod", signature(x = "numeric", y = "Matrix"),
205              function(x, y = NULL)  callGeneric(as.matrix(x), y))
206    
207  setMethod("solve", signature(a = "Matrix", b = "numeric"),  setMethod("solve", signature(a = "Matrix", b = "numeric"),
208            function(a, b, ...) callGeneric(a, as.matrix(b)))            function(a, b, ...) callGeneric(a, as.matrix(b)))
# Line 205  Line 217 
217            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
218  setMethod("crossprod", signature(x = "ANY", y = "Matrix"),  setMethod("crossprod", signature(x = "ANY", y = "Matrix"),
219            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))            function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
220    setMethod("tcrossprod", signature(x = "Matrix", y = "ANY"),
221              function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
222    setMethod("tcrossprod", signature(x = "ANY", y = "Matrix"),
223              function (x, y = NULL) .bail.out.2(.Generic, class(x), class(y)))
224    
225    ## cheap fallbacks
226    setMethod("crossprod", signature(x = "Matrix", y = "Matrix"),
227              function(x, y = NULL) t(x) %*% y)
228    setMethod("tcrossprod", signature(x = "Matrix", y = "Matrix"),
229              function(x, y = NULL) x %*% t(y))
230    
231  ## There are special sparse methods; this is a "fall back":  ## There are special sparse methods; this is a "fall back":
232  setMethod("kronecker", signature(X = "Matrix", Y = "ANY",  setMethod("kronecker", signature(X = "Matrix", Y = "ANY",

Legend:
Removed from v.1330  
changed lines
  Added in v.1331

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