Functions of Rational Numbers

# S4 method for rationalS4
Math(x)

# S3 method for rationalS3
Math(x, ...)

# S3 method for rationalR6
Math(x, ...)

# S4 method for rationalS4
Math2(x)

# S4 method for rationalS4
abs(x)

# S3 method for rationalS3
abs(x)

# S3 method for rationalR6
abs(x)

# S4 method for rationalS4
log(x, base = exp(1))

# S3 method for rationalS3
log(x, base = exp(1))

# S3 method for rationalR6
log(x, base = exp(1))

# S4 method for rationalS4
log10(x)

log10.rationalS3(x)

log10.rationalR6(x)

# S4 method for rationalS4
logb(x, base = exp(1))

logb.rationalS3(x, base = exp(1))

logb.rationalR6(x, base = exp(1))

# S4 method for rationalS4
log2(x)

log2.rationalS3(x)

log2.rationalR6(x)

# S4 method for rationalS4
gamma(x)

# S3 method for rationalS3
gamma(x)

# S3 method for rationalR6
gamma(x)

# S4 method for rationalS4
max(x, ..., na.rm = FALSE)

# S3 method for rationalS3
max(..., na.rm = FALSE)

# S3 method for rationalR6
max(..., na.rm = FALSE)

# S4 method for rationalS4
min(x, ..., na.rm = FALSE)

# S3 method for rationalS3
min(..., na.rm = FALSE)

# S3 method for rationalR6
min(..., na.rm = FALSE)

# S4 method for rationalS4
range(x, ..., na.rm = FALSE)

# S3 method for rationalS3
range(..., na.rm = FALSE)

# S3 method for rationalR6
range(..., na.rm = FALSE)

# S4 method for rationalS4
prod(x, ..., na.rm = FALSE)

# S3 method for rationalS3
prod(..., na.rm = FALSE)

# S3 method for rationalR6
prod(..., na.rm = FALSE)

# S4 method for rationalS4
sum(x, ..., na.rm = FALSE)

# S3 method for rationalS3
sum(..., na.rm = FALSE)

# S3 method for rationalR6
sum(..., na.rm = FALSE)

Arguments

x

rational numbers

...

rational numbers

base

the logarithm base in the logb function

na.rm

will NAs be removed from a collection before the computation is performed

Examples

floor(rational(5L, 2L, "S4"))
#> [1] 2
sign(rational(-1L, 2L, "S4"))
#> [1] -1
exp(rational(1L, 3L, "S3"))
#> [1] 1.395612
exp(rational(1L, 3L, "R6"))
#> [1] 1.395612
round(rational(5L, 2L, "S4"), 0)
#> [1] 2
x <- abs(rational(-2L, 3L, "S4")) stopifnot("rationalS4" %in% class(x)) x <- abs(rational(-2L, 3L, "S3")) stopifnot("rationalS3" %in% class(x)) x <- abs(rational(-2L, 3L, "R6")) stopifnot("rationalR6" %in% class(x)) log(rational(2L, 5L, "S4"))
#> [1] -0.9162907
log(rational(2L, 5L, "S3"))
#> [1] -0.9162907
log(rational(2L, 5L, "R6"))
#> [1] -0.9162907
log10(rational(2L, 5L, "S4"))
#> [1] -0.39794
log10(rational(2L, 5L, "S3"))
#> [1] -0.39794
log10(rational(2L, 5L, "R6"))
#> [1] -0.39794
logb(rational(2L, 5L, "S4"), base = 5)
#> [1] -0.5693234
logb(rational(2L, 5L, "S3"), base = 5)
#> [1] -0.5693234
logb(rational(2L, 5L, "R6"), base = 5)
#> [1] -0.5693234
log2(rational(2L, 5L, "S4"))
#> [1] -1.321928
log2(rational(2L, 5L, "S3"))
#> [1] -1.321928
log2(rational(2L, 5L, "R6"))
#> [1] -1.321928
gamma(rational(2L, 5L, "S4"))
#> [1] 2.21816
gamma(rational(2L, 5L, "S3"))
#> [1] 2.21816
gamma(rational(2L, 5L, "R6"))
#> [1] 2.21816
max(rational(c(2L, 3L), c(5L, 1L), "S4"))
#> (3 / 1) = 3
max(rational(c(2L, 3L), c(5L, 1L), "S3"))
#> [1] "(3 / 1) = 3"
max(rational(c(2L, 3L), c(5L, 1L), "R6"))
#> [1] "(3 / 1) = 3"
min(rational(c(2L, 3L), c(5L, 1L), "S4"))
#> (2 / 5) = 0.4
min(rational(c(2L, 3L), c(5L, 1L), "S3"))
#> [1] "(2 / 5) = 0.4"
min(rational(c(2L, 3L), c(5L, 1L), "R6"))
#> [1] "(2 / 5) = 0.4"
range(rational(c(2L, 3L), c(5L, 1L), "S4"))
#> [[1]] #> (2 / 5) = 0.4 #> [[2]] #> (3 / 1) = 3
range(rational(c(2L, 3L), c(5L, 1L), "S3"))
#> [[1]] #> [1] "(2 / 5) = 0.4" #> #> [[2]] #> [1] "(3 / 1) = 3" #>
range(rational(c(2L, 3L), c(5L, 1L), "R6"))
#> [[1]] #> [1] "(2 / 5) = 0.4" #> #> [[2]] #> [1] "(3 / 1) = 3" #>
prod(rational(c(2L, 3L), c(5L, 1L), "S4"))
#> (6 / 5) = 1.2
prod(rational(c(2L, 3L), c(5L, 1L), "S3"))
#> [1] "(6 / 5) = 1.2"
prod(rational(c(2L, 3L), c(5L, 1L), "R6"))
#> [1] "(6 / 5) = 1.2"
sum(rational(c(2L, 3L), c(5L, 1L), "S4"))
#> (17 / 5) = 3.4
sum(rational(c(2L, 3L), c(5L, 1L), "S3"))
#> [1] "(17 / 5) = 3.4"
sum(rational(c(2L, 3L), c(5L, 1L), "R6"))
#> [1] "(17 / 5) = 3.4"