he poly module contains the public classes Poly, Piece, PiecewisePoly and the
public functions Abs,Pow,Sqrt,T,S,Op,Convolution.
The class Poly is a representation of a polynomial. Piece is a representation
of a left-closed, right-open interval. PiecewisePoly is a representation of a
piecewise polynomial function with compact support.
The functions Abs and Sqrt take a PiecewisePoly object and return a callable
object. Pow returns a PiecewisePoly object.
T is a transport operation. S is a scale operation. Op is a combined transport
and scale. These take Piece,Poly or PiecewisePoly and act as described in the
section
(
Elementary
definitions of wavelet analysis
).
The function Convolution performs the convolution of two piecewise polynomial
functions.
The object PiecewisePoly is equipped with algebraic operations, taking an
integral and restricting it to another interval.
The example code below assumes that the R Communicator of the section
(
Python to R Communicator
) is
installed and the pyServer is running in an R shell. The following function
plots a graph of a function given by a poly.PiecewisePoly object.
import r_com
def plotPoly(func,N=10000) :
"Plot
a PiecewisePoly-nomial via r_com"
spt=func.support()
a=numpy.floor(spt.a())
b=numpy.ceil(spt.b())
h=1.0*(b-a)/N
x=[a+h*i
for i in range(0,N+1)]
y=[func(xx)
for xx in x]
r_com.r.set('x',x)
r_com.r.set('y',y)
r_com.r.plot(r_com.r('x'),r_com.r('y'))
pp=plotPoly
Consider the following session.
The line [2] constructs a PiecewisePoly object. The argument of poly.Poly is a
list of coefficients of the polynomial f(x)=1. The two arguments of poly.Piece
are boundaries of the interval. The poly.PiecewisePoly accepts a list of
tuples.
The example below constructs and plots a "centered hut" along the same
guidelines.
Algebraic
operations, integration and convolution are illustrated in the following
session.
|