The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

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 e1 must be given, a gmpoly object; for a binary operator, at least one of e1 and e2 must be a gmpoly object, and the other must a gmpoly object as well or a scalar; the power operator (^) is an exception: one can only raise a gmpoly object to a positive integer power

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 "x^(1,2,1) + 4 x^(0,2,3)", or you can define the polynomial with coeffs and powers; in this case set string to NULL or to nothing (i.e. missing)

coeffs

the coefficients of the polynomial, in case you don't define it with the string argument; this must be a vector of bigq numbers

powers

the powers of the polynomial, in case you don't define it with the string argument; this must be a matrix of integers, one row for each term (hence nrow(powers) must equal length(coeffs)), and the number of columns is the number of variables

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 gmpoly object

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 as.bigq function is applied to this argument, so it can be e.g. an integer or a character string such as "2/3" (avoid decimal numbers)

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 gmpoly object

x

either a bigq vector, or a bigq matrix; in the later case, the evaluation is performed for each row of the matrix

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 gmpoly object

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 gmpoly object

...

ignored

Value

No value, just prints the polynomial.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.