The R Project SVN R-packages

Rev

Rev 1321 | Rev 1833 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1321 Rev 1388
Line 9... Line 9...
9
 
9
 
10
setAs("dMatrix", "matrix",
10
setAs("dMatrix", "matrix",
11
      function(from) as(as(from, "dgeMatrix"), "matrix"))
11
      function(from) as(as(from, "dgeMatrix"), "matrix"))
12
 
12
 
13
## Methods for operations where one argument is integer
13
## Methods for operations where one argument is integer
-
 
14
## No longer made use of (and confusing hence) since R version 2.1.0
-
 
15
## where "integer" goes as part ofa "numeric"
14
 
16
 
-
 
17
## Note: Use as.matrix() {not directly array()} :
15
setMethod("%*%", signature(x = "dMatrix", y = "integer"),
18
##  1) to ensure consistency with "numeric" (non-matrix)
16
          function(x, y)
19
##  2) names -> dimnames {potentially}
17
          callGeneric(x, array(as.numeric(y), c(length(y), 1))),
20
## setMethod("%*%", signature(x = "dMatrix", y = "integer"),
18
          valueClass = "dgeMatrix")
21
##           function(x, y) callGeneric(x, as.numeric(y)))
19
 
22
 
20
setMethod("%*%", signature(x = "integer", y = "dMatrix"),
23
## setMethod("%*%", signature(x = "integer", y = "dMatrix"),
21
          function(x, y)
-
 
22
          callGeneric(array(as.numeric(x), c(1, length(x))), y),
24
##           function(x, y) callGeneric(as.numeric(x), y))
23
          valueClass = "dgeMatrix")
-
 
24
 
25
 
25
setMethod("crossprod", signature(x = "dMatrix", y = "integer"),
26
## setMethod("crossprod", signature(x = "dMatrix", y = "integer"),
26
          function(x, y = NULL)
-
 
27
          callGeneric(x, array(as.numeric(y), c(length(y), 1))),
27
##           function(x, y = NULL) callGeneric(x, as.numeric(y)))
28
          valueClass = "dgeMatrix")
-
 
29
 
28
 
30
setMethod("crossprod", signature(x = "integer", y = "dMatrix"),
29
## setMethod("crossprod", signature(x = "integer", y = "dMatrix"),
31
          function(x, y = NULL)
30
##           function(x, y = NULL) callGeneric(as.numeric(x), y))
32
          callGeneric(array(as.numeric(x), c(1, length(x))), y),
-
 
33
          valueClass = "dgeMatrix")
-
 
34
 
31
 
35
setMethod("solve", signature(a = "dMatrix", b = "integer"),
32
## setMethod("solve", signature(a = "dMatrix", b = "integer"),
36
          function(a, b, ...)
-
 
37
          callGeneric(a, array(as.numeric(b), c(length(b), 1))),
33
##           function(a, b, ...) callGeneric(a, as.numeric(b)))
38
          valueClass = "dgeMatrix")
-
 
39
 
34
 
40
 
35
 
41
## Group Methods, see ?Arith (e.g.)
36
## Group Methods, see ?Arith (e.g.)
42
## -----
37
## -----
43
 
38