R/operators.R

# 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)
    )
  }
)

Try the aion package in your browser

Any scripts or data that you put into this service are public.

aion documentation built on Oct. 4, 2024, 5:07 p.m.