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 2015, Wed Jul 25 14:17:24 2007 UTC revision 2036, Mon Aug 6 12:03:47 2007 UTC
# Line 209  Line 209 
209    
210  setMethod("%*%", signature(x = "Matrix", y = "numeric"),  setMethod("%*%", signature(x = "Matrix", y = "numeric"),
211            function(x, y) callGeneric(x, as.matrix(y)))            function(x, y) callGeneric(x, as.matrix(y)))
   
212  setMethod("%*%", signature(x = "numeric", y = "Matrix"),  setMethod("%*%", signature(x = "numeric", y = "Matrix"),
213            function(x, y) callGeneric(matrix(x, nrow = 1, byrow=TRUE), y))            function(x, y) callGeneric(matrix(x, nrow = 1, byrow=TRUE), y))
214    
215    setMethod("%*%", signature(x = "Matrix", y = "matrix"),
216              function(x, y) callGeneric(x, Matrix(y)))
217    setMethod("%*%", signature(x = "matrix", y = "Matrix"),
218              function(x, y) callGeneric(Matrix(x), y))
219    
220    
221  setMethod("crossprod", signature(x = "Matrix", y = "numeric"),  setMethod("crossprod", signature(x = "Matrix", y = "numeric"),
222            function(x, y = NULL) callGeneric(x, as.matrix(y)))            function(x, y = NULL) callGeneric(x, as.matrix(y)))
223  setMethod("crossprod", signature(x = "numeric", y = "Matrix"),  setMethod("crossprod", signature(x = "numeric", y = "Matrix"),
224            function(x, y = NULL)  callGeneric(as.matrix(x), y))            function(x, y = NULL)  callGeneric(as.matrix(x), y))
225    
226    setMethod("crossprod", signature(x = "Matrix", y = "matrix"),
227              function(x, y) callGeneric(x, Matrix(y)))
228    setMethod("crossprod", signature(x = "matrix", y = "Matrix"),
229              function(x, y) callGeneric(Matrix(x), y))
230    
231  ## The as.matrix() promotion seems illogical to MM,  ## The as.matrix() promotion seems illogical to MM,
232  ## but is according to help(tcrossprod, package = "base") :  ## but is according to help(tcrossprod, package = "base") :
233  setMethod("tcrossprod", signature(x = "Matrix", y = "numeric"),  setMethod("tcrossprod", signature(x = "Matrix", y = "numeric"),
234            function(x, y = NULL) callGeneric(x, as.matrix(y)))            function(x, y = NULL) callGeneric(x, as.matrix(y)))
235  setMethod("tcrossprod", signature(x = "numeric", y = "Matrix"),  setMethod("tcrossprod", signature(x = "numeric", y = "Matrix"),
236            function(x, y = NULL)  callGeneric(as.matrix(x), y))            function(x, y = NULL)  callGeneric(as.matrix(x), y))
237    setMethod("tcrossprod", signature(x = "Matrix", y = "matrix"),
238              function(x, y) callGeneric(x, Matrix(y)))
239    setMethod("tcrossprod", signature(x = "matrix", y = "Matrix"),
240              function(x, y) callGeneric(Matrix(x), y))
241    
242  ## maybe not optimal  ## maybe not optimal
243  setMethod("solve", signature(a = "Matrix", b = "missing"),  setMethod("solve", signature(a = "Matrix", b = "missing"),
244            function(a, b, ...) solve(a, Diagonal(nrow(a))))            function(a, b, ...) solve(a, Diagonal(nrow(a))))
245    
246  setMethod("solve", signature(a = "Matrix", b = "numeric"),  setMethod("solve", signature(a = "Matrix", b = "numeric"),
247            function(a, b, ...) callGeneric(a, as.matrix(b)))            function(a, b, ...) callGeneric(a, Matrix(b)))
248    setMethod("solve", signature(a = "Matrix", b = "matrix"),
249              function(a, b, ...) callGeneric(a, Matrix(b)))
250    setMethod("solve", signature(a = "matrix", b = "Matrix"),
251              function(a, b, ...) callGeneric(Matrix(a), b))
252    
253  ## when no sub-class method is found, bail out  ## when no sub-class method is found, bail out
254  setMethod("solve", signature(a = "Matrix", b = "matrix"),  setMethod("solve", signature(a = "Matrix", b = "matrix"),
255            function(a, b, ...) .bail.out.2("solve", class(a), "matrix"))            function(a, b, ...) .bail.out.2("solve", class(a), "matrix"))
256  setMethod("solve", signature(a = "Matrix", b = "Matrix"),  setMethod("solve", signature(a = "Matrix", b = "Matrix"),
257            function(a, b, ...) .bail.out.2("solve", class(a), class(b)))            function(a, b, ...) .bail.out.2("solve", class(a), class(b)))
258    setMethod("solve", signature(a = "Matrix", b = "matrix"),
259              function(a, b, ...) .bail.out.2("solve", class(a), class(b)))
260    setMethod("solve", signature(a = "matrix", b = "Matrix"),
261              function(a, b, ...) .bail.out.2("solve", class(a), class(b)))
262    
263  ## bail-out methods in order to get better error messages  ## bail-out methods in order to get better error messages
264  setMethod("%*%", signature(x = "Matrix", y = "Matrix"),  setMethod("%*%", signature(x = "Matrix", y = "Matrix"),

Legend:
Removed from v.2015  
changed lines
  Added in v.2036

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