| ArithmeticGMP {rcdd} | R Documentation |
GMP Rational Arithmetic
Description
Add, subtract, multiply, or divide one object to/from/by another using GMP (GNU multiple precision) rational arithmetic. Any size integers in the numerator and denominator are allowed.
Usage
qpq(x, y)
qmq(x, y)
qxq(x, y)
qdq(x, y)
qmatmult(x, y)
qsum(x)
qprod(x)
qmax(x)
qmin(x)
qsign(x)
qneg(x)
qabs(x)
qinv(x)
Arguments
x, y |
objects of type |
Details
qpq is “plus”,
qmq is “minus”,
qxq is “times”,
qdq is “divide”.
Divide by zero is an error. There are no rational NA, NaN, Inf.
qsum is vectorizing summation like sum for ordinary numeric.
qprod is vectorizing product like prod for ordinary numeric.
qmax is like max for ordinary numeric.
qmin is like min for ordinary numeric.
qsign is vectorizing sign like sign for ordinary numeric.
qmatmult is matrix multiplication like %*% for ordinary
numeric; both arguments must be matrices.
qneg is vectorizing negation like unary minus for ordinary numeric.
qabs is vectorizing absolute value like abs for ordinary numeric.
qinv is vectorizing inversion like 1 / x for ordinary numeric.
Value
an object of the same form as x that is the sum, difference,
product, quotient, or sign or (for qsum and qprod)
a scalar that is the sum or product.
See Also
Examples
qmq("1/3", "1/2")
# note inexactness of floating point representations
qmq("1/5", 1/5)
qdq("1/5", 1/5)
qsum(c("1", "1/2", "1/4", "1/8"))
qprod(c("1", "1/2", "1/4", "1/8"))
qmax(c("-1", "1/2", "1/-4", "1/8"))
qmin(c("-1", "1/2", "1/-4", "1/8"))
qsign(c("-1", "1/2", "1/-4", "1/8"))
qmatmult(matrix(c("1", "2", "3", "4"), 2, 2),
matrix(c("1/1", "1/2", "1/3", "1/4"), 2, 2))
qneg(seq(-3, 3))