/
operators.R
58 lines (55 loc) · 1.22 KB
/
operators.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# OPERATORS
#' @include AllGenerics.R
NULL
# "+", "-", "*", "^", "%%", "%/%", "/"
#' @export
#' @rdname arithmetic
#' @aliases Arith,RataDie,RataDie-method
setMethod(
f = "Arith",
signature = c(e1 = "RataDie", e2 = "RataDie"),
definition = function(e1, e2) {
z <- methods::callGeneric(e1@.Data, e2@.Data)
switch(
.Generic[[1]],
`+` = return(.RataDie(z)),
`-` = return(.RataDie(z)),
return(z)
)
}
)
#' @export
#' @rdname arithmetic
#' @aliases Arith,numeric,RataDie-method
setMethod(
f = "Arith",
signature = c(e1 = "numeric", e2 = "RataDie"),
definition = function(e1, e2) {
z <- methods::callGeneric(e1, e2@.Data)
switch(
.Generic[[1]],
`+` = return(.RataDie(z)),
`-` = return(.RataDie(z)),
`*` = return(.RataDie(z)),
return(z)
)
}
)
#' @export
#' @rdname arithmetic
#' @aliases Arith,RataDie,numeric-method
setMethod(
f = "Arith",
signature = c(e1 = "RataDie", e2 = "numeric"),
definition = function(e1, e2) {
z <- methods::callGeneric(e1@.Data, e2)
switch(
.Generic[[1]],
`+` = return(.RataDie(z)),
`-` = return(.RataDie(z)),
`*` = return(.RataDie(z)),
`/` = return(.RataDie(z)),
return(z)
)
}
)