|
|
last edited 11 years ago by test1 |
1 2 3 4 5 6 7 8 9 10 11 12 | ||
Editor: Bill Page
Time: 2008/08/24 07:08:22 GMT-7 |
||
Note: compile functions |
added:
-- functions are first compiled here
--
http://en.wikipedia.org/wiki/Tensor_product
A tensor product is "the most general bilinear operation" available in a specified domain of computation, satisfying:
We can use the domain constructor Sum
[SandBoxSum]?
)lib SUM
Sum is now explicitly exposed in frame initial Sum will be automatically loaded when needed from /var/zope2/var/LatexWiki/SUM.NRLIB/code.o
First we can define some recursive operations on the polynomials
scanPoly(p,n) == _ (p=0 => 0; mapMonomial(leadingMonomial(p),n)+scanPoly(reductum p,n))
mapMonomial(p,n) == _ monomial(coefficient(p,degree p),scanIndex(degree(p),n))$SMP(Integer,Sum(Symbol,Symbol))
scanIndex(p,n) == _ (zero? p => 0$IndexedExponents(Sum(Symbol,Symbol)); _ monomial(leadingCoefficient(p), _ if n=1 then in1(leadingSupport(p))$Sum(Symbol,Symbol) _ else in2(leadingSupport(p))$Sum(Symbol,Symbol) _ )$IndexedExponents(Sum(Symbol,Symbol))+ _ scanIndex(reductum(p),n))
For example:
-- functions are first compiled here -- scanPoly(x,1)
Compiling function scanIndex with type (IndexedExponents Symbol, Integer) -> IndexedExponents Sum(Symbol,Symbol) ; (DEFUN |*2;scanIndex;1;initial| ...) is being compiled. ;; The variable |*2;scanIndex;1;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
Compiling function mapMonomial with type (Polynomial Integer,Integer ) -> SparseMultivariatePolynomial(Integer,Sum(Symbol,Symbol)) ; (DEFUN |*2;mapMonomial;1;initial| ...) is being compiled. ;; The variable |*2;mapMonomial;1;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
Compiling function scanPoly with type (Polynomial Integer,Integer) -> SparseMultivariatePolynomial(Integer,Sum(Symbol,Symbol)) ; (DEFUN |*2;scanPoly;3;initial| ...) is being compiled. ;; The variable |*2;scanPoly;3;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
Compiling function scanPoly with type (Polynomial Integer,Integer) -> SparseMultivariatePolynomial(Integer,Sum(Symbol,Symbol))
;;; *** |*2;scanPoly;3;initial| REDEFINED ; (DEFUN |*2;scanPoly;3;initial| ...) is being compiled. ;; The variable |*2;scanPoly;3;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
Compiling function scanPoly with type (Variable x,Integer) -> SparseMultivariatePolynomial(Integer,Sum(Symbol,Symbol)) ; (DEFUN |*2;scanPoly;1;initial| ...) is being compiled. ;; The variable |*2;scanPoly;1;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
(1) |
injects the polynomial x
in to the tensor product. So
now the full tensor product is just:
tensorPoly(p,q) == _ scanPoly(p,1)*scanPoly(q,2)
For example:
p:=2*x^2+3
(2) |
q:=5*x*y+7*y+11
(3) |
r:=tensorPoly(p,q)
Compiling function tensorPoly with type (Polynomial Integer, Polynomial Integer) -> SparseMultivariatePolynomial(Integer,Sum( Symbol,Symbol)) ; (DEFUN |*2;tensorPoly;1;initial| ...) is being compiled. ;; The variable |*2;tensorPoly;1;initial;MV| is undefined. ;; The compiler will assume this variable is a global.
(4) |