spad
)abbrev domain TENSALG TensorAlgebra
TensorAlgebra(M,R,B) : Exports == Implementation where
M:FreeModuleCategory(R, B)
R:CommutativeRing
B:OrderedSet
OF ==> OutputForm
NNI ==> NonNegativeInteger
FMB ==> FreeMonoid B
CTOF ==> CoercibleTo OutputForm
FMCRB ==> FreeModuleCategory(R,FMB)
GRALR ==> GradedAlgebra(R,NNI)
XFABR ==> XFreeAlgebra(B,R)
XDPBR ==> XDistributedPolynomial(B,R)
TERM ==> Record(k:FMB,c:R)
Exports == Join(FMCRB, XFABR, GRALR) with
coerce : B -> %
convert : FMB -> OutputForm
Implementation == XDPBR add
Rep := XDPBR
product(x,y) == x*y -- GradedAlgebra, pro forma
convert(x:FMB):OutputForm ==
x=1$FMB => empty()$OF
length(x)$FMB = 1 => x::OF
length(x)$FMB = 2 => tensor(first(x)::OF,rest(x)::OF)$OF
tensor(first(x)::OF, convert(rest x))
coerce(x:%):OutputForm ==
zero? x => empty()$OF
x=1$% => outputForm(1)$OF
c:R:=leadingCoefficient(x)
if c=1 then cof:=empty()$OF else cof:=c::OF
kof:OF:=cof * convert(leadingSupport(x))
zero? reductum(x) => kof
kof + reductum(x)::OF
spad
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/579490114000940455-25px001.spad
using old system compiler.
TENSALG abbreviates domain TensorAlgebra
------------------------------------------------------------------------
initializing NRLIB TENSALG for TensorAlgebra
compiling into NRLIB TENSALG
compiling exported product : ($,$) -> $
Time: 0.02 SEC.
compiling exported convert : FreeMonoid B -> OutputForm
Time: 0 SEC.
compiling exported coerce : $ -> OutputForm
Time: 0.01 SEC.
****** Domain: R already in scope
augmenting R: (OrderedAbelianMonoidSup)
(time taken in buildFunctor: 10)
;;; *** |TensorAlgebra| REDEFINED
;;; *** |TensorAlgebra| REDEFINED
Time: 0.02 SEC.
Cumulative Statistics for Constructor TensorAlgebra
Time: 0.05 seconds
--------------non extending category----------------------
.. TensorAlgebra(#1,#2,#3) of cat
(|Join| (|FreeModuleCategory| |#2| (|FreeMonoid| |#3|))
(|XFreeAlgebra| |#3| |#2|)
(|GradedAlgebra| |#2| (|NonNegativeInteger|))
(CATEGORY |domain| (SIGNATURE |coerce| ($ |#3|))
(SIGNATURE |convert| ((|OutputForm|) (|FreeMonoid| |#3|))))) has no
(|XPolynomialsCat| |#3| |#2|) finalizing NRLIB TENSALG
Processing TensorAlgebra for Browser database:
--->-->TensorAlgebra(constructor): Not documented!!!!
--->-->TensorAlgebra((coerce (% B))): Not documented!!!!
--->-->TensorAlgebra((convert ((OutputForm) (FreeMonoid B)))): Not documented!!!!
--->-->TensorAlgebra(): Missing Description
; compiling file "/var/aw/var/LatexWiki/TENSALG.NRLIB/TENSALG.lsp" (written 01 FEB 2020 05:44:10 PM):
; /var/aw/var/LatexWiki/TENSALG.NRLIB/TENSALG.fasl written
; compilation finished in 0:00:00.031
------------------------------------------------------------------------
TensorAlgebra is now explicitly exposed in frame initial
TensorAlgebra will be automatically loaded when needed from
/var/aw/var/LatexWiki/TENSALG.NRLIB/TENSALG
fricas
B:=OrderedVariableList [e[i] for i in 1..5]
Type: Type
fricas
e:=enumerate()$B
Type: List(OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
R:=Expression Integer
Type: Type
fricas
R has CommutativeRing
Type: Boolean
fricas
M:=FreeModule(R, B)
Type: Type
fricas
-- This is the object of interest
TA:=TensorAlgebra(M,R,B)
Type: Type
fricas
-- coerce basis to TA
b:=[a::TA for a in e]
Type: List(TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])))
fricas
v1:=x*b.1+y*b.2-z*b.3
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
v2:=y^n*b.1-cos(x)*b.2
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
v3:=sin(x+y+z)*b.3
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
t0:=exp(-x-y-z)*1$TA
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
t1:=b.1*b.2*b.3*b.4+v1
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
t2:=v1*v2+v1*v3*b.5+t0*b.4*b.3
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
-- product(x,y) same as x*y
p1:=product(v1,v2)
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
p2:=product(product(v1,v3),t1)
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
p3:=tan(x)*1$TA
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
s1:=p1+p2+p3
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
---
degree(v1*v2*v3*t1)
fricas
listOfTerms (v1*v1*v2*v3)
Type: List(Record(k: FreeMonoid
?(OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
c: Expression(Integer)))
fricas
degree (1$TA)
Type: NonNegativeInteger
?
fricas
v1+1$TA
Type: TensorAlgebra
?(FreeModule
?(Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
Expression(Integer),
OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]]))
fricas
listOfTerms %
Type: List(Record(k: FreeMonoid
?(OrderedVariableList
?([e[1],
e[2],
e[3],
e[4],
e[5]])),
c: Expression(Integer)))