definePoly {SimplicialCubature} | R Documentation |
Define, evaluate, or print a polynomial
Description
Utility functions to work with a multivariate polynomial.
Usage
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_{i=1}^{\mathrm{length(coef)}} \mathrm{coef}_i x_1^{k[i,1]} x_2^{k[i,2]}
\cdots x_n^{k[i,n]}
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
Examples
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