Type: | Package |
Title: | Multivariate Polynomials with Rational Coefficients |
Version: | 1.1.0 |
Date: | 2022-02-21 |
Author: | Stéphane Laurent |
Maintainer: | Stéphane Laurent <laurent_step@outlook.fr> |
Description: | Symbolic calculation (addition or multiplication) and evaluation of multivariate polynomials with rational coefficients. |
License: | GPL-3 |
Encoding: | UTF-8 |
Imports: | gmp, purrr, mvp, english |
RoxygenNote: | 7.1.2 |
URL: | https://github.com/stla/gmpoly |
BugReports: | https://github.com/stla/gmpoly/issues |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2022-03-20 04:27:56 UTC; SDL96354 |
Repository: | CRAN |
Date/Publication: | 2022-03-20 04:40:02 UTC |
Arithmetic operators for multivariate polynomials
Description
Arithmetic operators for multivariate polynomials
Usage
## S3 method for class 'gmpoly'
Ops(e1, e2 = NULL)
Arguments
e1 , e2 |
for an unary operator, only |
Value
A gmpoly
object.
Examples
library(gmpoly)
pol <- gmpoly("4 x^(2, 1, 1) + 1/2 x^(0,1,0)")
+pol
-pol
2 * pol
pol / 2
pol + 5
pol - 5
pol^2
pol1 <- gmpoly("2 x^(1,1) - 5/3 x^(0,1)")
pol2 <- gmpoly("-2 x^(1,1) + 3 x^(2,1)")
pol1 + pol2
pol1 * pol2
pol1 == pol2
pol1 != pol2
Define a multivariate polynomial
Description
Define a multivariate polynomial from a string or from its coefficients and powers.
Usage
gmpoly(string, coeffs = NULL, powers = NULL)
Arguments
string |
a string such as |
coeffs |
the coefficients of the polynomial, in case you don't define
it with the |
powers |
the powers of the polynomial, in case you don't define it
with the |
Value
A gmpoly
object.
Examples
library(gmpoly)
gmpoly("5/2 x^(2,3) + 3 x^(1,1)")
gmpoly("5/2 x^(2,3) - 3 x^(1,1)")
gmpoly("-x^(1,2,3) + 4/7 x^(3,1,1)")
library(gmp)
gmpoly(
coeffs = as.bigq(c(5, 7), c(8, 9)),
powers = rbind(c(1, 1, 1), c(2, 2, 2))
)
Conversion to 'mvp' polynomial
Description
Convert a gmpoly
polynomial to a
mvp
polynomial.
Usage
gmpoly2mvp(pol)
Arguments
pol |
a |
Value
A mvp
object.
Examples
library(gmpoly)
pol <- gmpoly("5/2 x^(2,2,3) + 3 x^(1,0,1)")
gmpoly2mvp(pol)
Constant multivariate polynomial
Description
Constructs a constant multivariate polynomial.
Usage
gmpolyConstant(m, value)
Arguments
m |
number of variables, a strictly positive integer |
value |
the constant value of the polynomial; the
|
Value
A gmpoly
object.
Examples
library(gmpoly)
gmpolyConstant(3, "2/3")
Evaluation of a multivariate polynomial
Description
Evaluates a gmpoly
multivariate polynomial for given
values of the variables.
Usage
gmpolyEval(pol, x)
Arguments
pol |
a |
x |
either a |
Value
A bigq
number or vector.
Examples
library(gmpoly)
library(gmp)
pol <- gmpoly("5/2 x^(2,3) + 3 x^(1,1)")
gmpolyEval(pol, as.bigq(c(1, 1)))
x <- rbind(
t(as.bigq(c(1, 1))),
t(as.bigq(c(3, 4), c(4, 3)))
)
gmpolyEval(pol, x)
Grow polynomial
Description
Grow a multivariate polynomial by including a new variable.
Usage
gmpolyGrow(pol)
Arguments
pol |
a |
Value
The "same" multivariate polynomial as pol
, except that it
has an additional variable.
Examples
library(gmpoly)
pol <- gmpoly("3 x^(1,2) - 1/7 x^(5,3)")
gmpolyGrow(pol)
Print a multivariate polynomial
Description
Print a multivariate polynomial of class gmpoly
.
Usage
## S3 method for class 'gmpoly'
print(x, ...)
Arguments
x |
a |
... |
ignored |
Value
No value, just prints the polynomial.