definePoly: Define, evaluate, or print a polynomial

Description Usage Arguments Details Value Note See Also Examples

View source: R/SimplicialCubature.R

Description

Utility functions to work with a multivariate polynomial.

Usage

1
2
3
definePoly(coef, k)
printPoly( p, num.digits )
evalPoly( x, p, useTerm=rep(TRUE, length(p$coef) ) )

Arguments

coef

a vector of coefficients, one for each term of p(x)

k

a matrix of (non-negative, integer) powers

p

a polynomial, defined by definePoly

num.digits

number of digits to print for the coefficients of the polynomial

x

a (n x m) matrix, with columns containing the vectors where the polynomial should be evaluated

useTerm

vector of boolean values: if useTerm[i]=TRUE, term i is included in the evaluation; if useTerm[i]=FALSE, term i is not included.

Details

These are utility functions for use with integrateSimplexPolynomial. definePoly is used to define a polynomial:

p(x)=sum(coef[i] * x[1]^k[i,1]* x[2]^k[i,2] * ... * x[n]^k[i,n]), where the sum is over i=1,...,length(coef).

printPoly prints a polynomial in human readable form.

evalPoly evaluates a polynomial at each of the vectors x[,1],x[,2],...,x[,m]. The optional argument useTerm is for internal use.

See example below.

Value

For definePoly, a list is returned. That list can be used by integrateSimplexPolynomial, printPoly, or evalPoly.

For printPoly, nothing is returned, but a human readable format is printed on the console.

For evalPoly, a vector of m values: y[i] = p(x[,i]).

Note

The internal definition of a polynomial may change in the future.

See Also

integrateSimplexPolynomial

Examples

1
2
3
p1 <- definePoly( c(3,5), matrix(c(3,0,0,0, 0,2,1,4), nrow=2, ncol=4, byrow=TRUE ) )
printPoly(p1)
evalPoly( c(1,3,1,2) , p1 ) # f(1,3,1,2) = 723

SimplicialCubature documentation built on Jan. 8, 2021, 5:40 p.m.