|
|
last edited 7 years ago by Bill Page |
1 2 3 | ||
Editor: Bill Page
Time: 2017/04/25 20:54:42 GMT+0 |
||
Note: version update |
changed: - Rep == FreeMonoid COLOR Rep ==> FreeMonoid COLOR changed: - Rep == Record(domain:Arity, codomain:Arity) Rep ==> Record(domain:Arity, codomain:Arity) changed: - Rep == FreeMonoid L Rep ==> FreeMonoid L changed: - fs:List % := [select(f,i) for i in 0..length(f)-1] - gs:List % := [select(g,i) for i in 0..length(g)-1] fs:List % := [select(f,i) for i in 0..#f-1] gs:List % := [select(g,i) for i in 0..#g-1]
Bi-graded two-color linear operators (transformations) over a finite n-dimensional vector space, including products and duals on a field . Members of this domain are morphisms where and (dual), etc. Products, permutations and composition (grafting) of morphisms are implemented. Operators are represented internally as tensors.
Operator composition and products can be visualized by oriented directed graphs. The graphs have a top and a bottom and arrows are directed either downwards or upwards.
External vertices in this graph represent vectors, tensors and their duals. Internal nodes and arcs (edges) represent linear operators. Edges may be one of two different "colors" (labelled + and - in the code that follows) or marked with arrows directed either downwards (+) or upwards (-). Horizontal juxtaposition (i.e. a horizontal cross-section) represents tensor product. Vertical juxtaposition of edges of the same color represents operator composition.
See examples and documentation below
I would be glad if you to make brief comments in the form at the bottom of this web page. For more detailed but related comments click discussion on the top menu.
Regards, Bill Page.
We try to start by defining the concept of a compact closed category.
Ref:
(1) -> <spad>
)abbrev domain ARITY Arity Arity(): Exports == Implementation where COLOR ==> OrderedVariableList ['_+,'_-] LIST2 ==> ListFunctions2 NNI ==> NonNegativeInteger RS ==> Record(gen:COLOR, exp:NNI)
Exports ==> Join(Monoid,RetractableTo COLOR) with index: PositiveInteger -> % dn: () -> % ++ default up: () -> % ++ dual 0: % ++ use 0 for identity "+": (%, %) -> % ++ composition size: % -> NonNegativeInteger len: % -> Integer color: (%, NNI) -> % overlap: (%, %) -> Record(lm:%, mm:%, rm:%) Implementation ==> FreeMonoid COLOR add Rep ==> FreeMonoid COLOR rep(x:%):Rep == x pretend Rep per(x:Rep):% == x pretend % index(x:PositiveInteger):% == per(index(x)$COLOR ::Rep) up():% == index(2) dn():% == index(1) 0:% == per 1 (f:% + g:%):% == per(rep f * rep g) coerce(x:%):OutputForm == (rep(x)=1 => message "0";rep(x)::OutputForm) -- size of FreeMonoid is just number of factors -- len is total length len(f:%):Integer == reduce(_+, map(x+->x.exp, factors rep f)$LIST2(RS, NNI), 0)$List(NNI) pretend Integer -- i'th element color(f:%, i:NNI):% == j:NNI:=0 for x in factors rep f repeat j:=j+x.exp if j>=i then return per coerce x.gen error "index error"</spad>
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7355925127427701597-25px001.spad using old system compiler. ARITY abbreviates domain Arity ------------------------------------------------------------------------ initializing NRLIB ARITY for Arity compiling into NRLIB ARITY processing macro definition Rep ==> FreeMonoid OrderedVariableList construct(QUOTE +,QUOTE -) compiling local rep : % -> FreeMonoid OrderedVariableList construct(QUOTE +, QUOTE -) ARITY;rep is replaced by x Time: 0 SEC.
compiling local per : FreeMonoid OrderedVariableList construct(QUOTE +,QUOTE -) -> % ARITY;per is replaced by x Time: 0 SEC.
compiling exported index : PositiveInteger -> % Time: 0 SEC.
compiling exported up : () -> % Time: 0 SEC.
compiling exported dn : () -> % Time: 0 SEC.
compiling exported Zero : () -> % Time: 0 SEC.
compiling exported + : (%,%) -> % Time: 0 SEC.
compiling exported coerce : % -> OutputForm Time: 0 SEC.
compiling exported len : % -> Integer Time: 0 SEC.
compiling exported color : (%,NonNegativeInteger) -> % Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |Arity| REDEFINED
;;; *** |Arity| REDEFINED Time: 0 SEC.
Warnings: [1] len: exp has no value [2] len: pretend(Integer) -- should replace by @ [3] color: exp has no value [4] color: gen has no value
Cumulative Statistics for Constructor Arity Time: 0.02 seconds
--------------non extending category---------------------- .. Arity of cat (|Join| (|Monoid|) (|RetractableTo| (|OrderedVariableList| (|construct| '+ '-))) (CATEGORY |domain| (SIGNATURE |index| (% (|PositiveInteger|))) (SIGNATURE |dn| (%)) (SIGNATURE |up| (%)) (SIGNATURE (|Zero|) (%) |constant|) (SIGNATURE + (% % %)) (SIGNATURE |size| ((|NonNegativeInteger|) %)) (SIGNATURE |len| ((|Integer|) %)) (SIGNATURE |color| (% % (|NonNegativeInteger|))) (SIGNATURE |overlap| ((|Record| (|:| |lm| %) (|:| |mm| %) (|:| |rm| %)) % %)))) has no (|RetractableTo| (|OrderedVariableList| (|construct| + -))) finalizing NRLIB ARITY Processing Arity for Browser database: --->-->Arity(constructor): Not documented!!!! --->-->Arity((index (% (PositiveInteger)))): Not documented!!!! --------(dn (%))--------- --------(up (%))--------- --------((Zero) (%) constant)--------- --->-->Arity(((Zero) (%) constant)): Improper first word in comments: use "use 0 for identity" --------(+ (% % %))--------- --->-->Arity((size ((NonNegativeInteger) %))): Not documented!!!! --->-->Arity((len ((Integer) %))): Not documented!!!! --->-->Arity((color (% % (NonNegativeInteger)))): Not documented!!!! --->-->Arity((overlap ((Record (: lm %) (: mm %) (: rm %)) % %))): Not documented!!!! --->-->Arity(): Missing Description ; compiling file "/var/aw/var/LatexWiki/ARITY.NRLIB/ARITY.lsp" (written 16 DEC 2024 10:17:15 PM):
; wrote /var/aw/var/LatexWiki/ARITY.NRLIB/ARITY.fasl ; compilation finished in 0:00:00.012 ------------------------------------------------------------------------ Arity is now explicitly exposed in frame initial Arity will be automatically loaded when needed from /var/aw/var/LatexWiki/ARITY.NRLIB/ARITY
)abbrev category CMONAL ClosedMonoidal ClosedMonoidal():Category == Ring with dom: % -> Arity ++ domain cod: % -> Arity ++ co-domain _/: (%,%) -> % ++ vertical composition f/g apply: (%, %) -> % ++ horizontal product f g = f*g "^": (%, Arity) -> % ++ colored power dagger: % -> % ++ reverse arrows: ++ cod f = dom dagger f ++ dom f = cod dagger f
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7854049118560040482-25px002.spad using old system compiler. CMONAL abbreviates category ClosedMonoidal ------------------------------------------------------------------------ initializing NRLIB CMONAL for ClosedMonoidal compiling into NRLIB CMONAL
;;; *** |ClosedMonoidal| REDEFINED Time: 0 SEC.
finalizing NRLIB CMONAL Processing ClosedMonoidal for Browser database: --->-->ClosedMonoidal(constructor): Not documented!!!! --------(dom ((Arity) %))--------- --------(cod ((Arity) %))--------- --------(/ (% % %))--------- --->-->ClosedMonoidal((/ (% % %))): Improper first word in comments: vertical "vertical composition \\spad{f/g}" --------(apply (% % %))--------- --->-->ClosedMonoidal((apply (% % %))): Improper first word in comments: horizontal "horizontal product \\spad{f} \\spad{g} = \\spad{f*g}" --------(^ (% % (Arity)))--------- --------(dagger (% %))--------- --->-->ClosedMonoidal(): Missing Description ; compiling file "/var/aw/var/LatexWiki/CMONAL.NRLIB/CMONAL.lsp" (written 16 DEC 2024 10:17:15 PM):
; wrote /var/aw/var/LatexWiki/CMONAL.NRLIB/CMONAL.fasl ; compilation finished in 0:00:00.000 ------------------------------------------------------------------------ ClosedMonoidal is now explicitly exposed in frame initial ClosedMonoidal will be automatically loaded when needed from /var/aw/var/LatexWiki/CMONAL.NRLIB/CMONAL
The initial object in this category is the domain ClosedProp? (Products and Permutations). The ClosedProp? domain represents everything that is "constant" about all the domains in this category. It can be defined as an endofunctor with only the information available about the category itself.
)abbrev domain CPROP ClosedProp ClosedProp(L:ClosedMonoidal): Exports == Implementation where
Exports ==> ClosedMonoidal with coerce: L -> %
Implementation ==> add Rep ==> Record(domain:Arity,codomain:Arity) rep(x:%):Rep == x pretend Rep per(x:Rep):% == x pretend %
coerce(f:%):OutputForm == dom(f)::OutputForm / cod(f)::OutputForm
coerce(f:L):% == per [dom f,cod f] -- coerce(f:L):% == per f
dom(x:%):Arity == rep(x).domain -- dom(x:%):NNI == dom rep x cod(x:%):Arity == rep(x).codomain -- cod(x:%):NNI == cod rep x --0:% == per [1,1] -- 0:% == per 0 1:% == per [1, 1] -- 1:% == per 1 -- evaluation (f:% / g:%):% == per [dom f, cod g] -- (f:% / g:%):% == per (rep f / rep g) -- product apply(f:%, g:%):% == per [dom f * dom g, cod f * cod g] -- apply(f:%, g:%):% == per apply(rep f, rep g) (f:% * g:%):% == per [dom f * dom g, cod f * cod g] --(f:% * g:%):% == per (rep f * rep g) -- sum --(f:% + g:%):% == per [dom f, cod f] --(f:% + g:%):% == per (rep f + rep g) dagger(f:%):% == per [cod f, dom f] (f:% ^ p:Arity):% == r:% := 1 for i in 1..len(p) repeat if color(p, i)=dn() then r:=r*f else r:=r*dagger(f) return r
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8579968413172847989-25px003.spad using old system compiler. CPROP abbreviates domain ClosedProp ------------------------------------------------------------------------ initializing NRLIB CPROP for ClosedProp compiling into NRLIB CPROP processing macro definition Rep ==> Record(domain: Arity,codomain: Arity) compiling local rep : % -> Record(domain: Arity, codomain: Arity) CPROP;rep is replaced by x Time: 0 SEC.
compiling local per : Record(domain: Arity,codomain: Arity) -> % CPROP;per is replaced by x Time: 0 SEC.
compiling exported coerce : % -> OutputForm Time: 0 SEC.
compiling exported coerce : L -> % Time: 0 SEC.
compiling exported dom : % -> Arity Time: 0 SEC.
compiling exported cod : % -> Arity Time: 0 SEC.
compiling exported One : () -> % Time: 0 SEC.
compiling exported / : (%,%) -> % Time: 0 SEC.
compiling exported apply : (%,%) -> % Time: 0 SEC.
compiling exported * : (%,%) -> % Time: 0 SEC.
compiling exported dagger : % -> % Time: 0 SEC.
compiling exported ^ : (%,Arity) -> % Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |ClosedProp| REDEFINED
;;; *** |ClosedProp| REDEFINED Time: 0 SEC.
Warnings: [1] dom: domain has no value [2] cod: codomain has no value
Cumulative Statistics for Constructor ClosedProp Time: 0 seconds
finalizing NRLIB CPROP Processing ClosedProp for Browser database: --->-->ClosedProp(constructor): Not documented!!!! --->-->ClosedProp((coerce (% L))): Not documented!!!! --->-->ClosedProp(): Missing Description ; compiling file "/var/aw/var/LatexWiki/CPROP.NRLIB/CPROP.lsp" (written 16 DEC 2024 10:17:15 PM):
; wrote /var/aw/var/LatexWiki/CPROP.NRLIB/CPROP.fasl ; compilation finished in 0:00:00.016 ------------------------------------------------------------------------ ClosedProp is now explicitly exposed in frame initial ClosedProp will be automatically loaded when needed from /var/aw/var/LatexWiki/CPROP.NRLIB/CPROP
The ClosedLinearOperator domain is ClosedMonoidal? over FreeMonoid OrderedVariables? ['_+,'_-]?, i.e. strings of symbols. The objects of this domain are all tensor powers of a vector space of fixed dimension. The arrows are linear operators that map from one object (tensor powers of vector space and it's dual) to another such power.
Ref: http://en.wikipedia.org/wiki/Category_of_vector_spaces
Faster tensors
)lib CARTEN
CartesianTensor is now explicitly exposed in frame initial CartesianTensor will be automatically loaded when needed from /var/aw/var/LatexWiki/CARTEN.NRLIB/CARTEN
)abbrev domain CLOP ClosedLinearOperator ClosedLinearOperator(gener:OrderedFinite,K:Field): Exports == Implementation where NNI ==> NonNegativeInteger Exports ==> Join(Ring, VectorSpace K, ClosedMonoidal, RetractableTo K) with arity: % -> ClosedProp % basisOut: () -> List % basisIn: () -> List % map: (K->K, %) -> % if K has Evalable(K) then Evalable(K) eval: % -> % ravel: % -> List K unravel: (ClosedProp %, List K) -> % coerce:(x:List Integer) -> % ++ identity for composition and permutations of its products coerce:(x:List None) -> % ++ [] = 1 elt: (%, %) -> % elt: (%, Integer) -> % elt: (%, Integer, Integer) -> % elt: (%, Integer, Integer, Integer) -> % _/: (Tuple %, Tuple %) -> % _/: (Tuple %, %) -> % _/: (%, Tuple %) -> % ++ yet another syntax for product ev: NNI -> % ++ (2, 0)-tensor for evaluation co: NNI -> % ++ (0, 2)-tensor for co-evaluation Implementation ==> add
LIST2 ==> ListFunctions2 dim:NNI := size()$gener T := CartesianTensor(1,dim, K) L := Record(domain:Arity, codomain:Arity, data:T) RR := Record(gen:L, exp:NNI) -- FreeMonoid provides unevaluated products Rep ==> FreeMonoid L rep(x:%):Rep == x pretend Rep per(x:Rep):% == x pretend % dimension():CardinalNumber == coerce dim
-- Prop (arity) dom(f:%):Arity == reduce(_*,map(x+->(x.gen.domain)^(x.exp), factors rep f)$LIST2(RR, Arity), 1)$List(Arity) cod(f:%):Arity == reduce(_*, map(x+->(x.gen.codomain)^(x.exp), factors rep f)$LIST2(RR, Arity), 1)$List(Arity) dagger(f:%):% == r:=1 for f1 in factors rep f repeat p:List Integer := concat [ _ [len(f1.gen.domain)+i for i in 1..len(f1.gen.codomain)], _ [i for i in 1..len(f1.gen.domain)]] r:= per(coerce [f1.gen.codomain, f1.gen.domain, reindex(f1.gen.data, p) ])^f1.exp * r return r
prod(f:L,g:L):L == r:T := product(f.data, g.data) -- dom(f) + cod(f) + dom(g) + cod(g) p:List Integer := concat _ [[i for i in 1..len(f.domain)], _ [len(f.domain)+len(f.codomain)+i for i in 1..len(g.domain)], _ [len(f.domain)+i for i in 1..len(f.codomain)], _ [len(f.domain)+len(g.domain)+len(f.codomain)+i for i in 1..len(g.codomain)]] -- dom(f) + dom(g) + cod(f) + cod(g) --output("prod p = ", p::OutputForm)$OutputPackage [(f.domain)*(g.domain), (f.codomain)*(g.codomain), reindex(r, p)]
dats(fs:List RR):L == r:L := [1,1, 1$T] -- scalar 1 as tensor for y in fs repeat t:L:=y.gen for n in 1..y.exp repeat r:=prod(r, t) return r
dat(f:Rep):L == dats factors f
arity(f:%):ClosedProp % == f::ClosedProp %
eval(f:%):% == per coerce dat(rep f)
retractIfCan(f:%):Union(K,"failed") == dom(f)=1 and cod(f)=1 => retract(dat(rep f).data)$T return "failed" retract(f:%):K == dom(f)=1 and cod(f)=1 => retract(dat(rep f).data)$T error "failed"
-- basis basisOut():List % == [per coerce [1,dn(), entries(row(1, i)$SquareMatrix(dim, K))::T] for i in 1..dim] basisIn():List % == [per coerce [dn(), 1, entries(row(1, i)$SquareMatrix(dim, K))::T] for i in 1..dim] ev(n:NNI):% == reduce(_+, [ dx^n * dx^n for dx in basisIn()])$List(%) co(n:NNI):% == reduce(_+, [ Dx^n * Dx^n for Dx in basisOut()])$List(%)
-- manipulation map(f:K->K,g:%):% == per coerce [dom g, cod g, unravel(map(f, ravel dat(rep g).data))$T] if K has Evalable(K) then eval(g:%, f:List Equation K):% == map((x:K):K+->eval(x, f), g) ravel(g:%):List K == ravel dat(rep g).data unravel(p:ClosedProp %, r:List K):% == dim^(len(dom(p)*cod(p)) pretend NNI) ~= #r => error "failed" per coerce [dom(p), cod(p), unravel(r)$T]
-- sum (f:% + g:%):% == dat(rep f).data=0 => g dat(rep g).data=0 => f dom(f) ~= dom(g) or cod(f) ~= cod(g) => error "arity" per coerce [dom f,cod f, dat(rep f).data+dat(rep g).data]
(f:% - g:%):% == dat(rep f).data=0 => g dat(rep g).data=0 => f dom(f) ~= dom(f) or cod(g) ~= cod(g) => error "arity" per coerce [dom f,cod f, dat(rep f).data-dat(rep g).data]
_-(f:%):% == per coerce [dom f,cod f, -dat(rep f).data]
(x:% = y:%):Boolean == if rep x = rep y then true else rep eval x = rep eval y
-- identity for sum (trivial zero map) 0 == per coerce [1,1, 0] zero?(f:%):Boolean == dat(rep f).data = 0 * dat(rep f).data -- identity for product 1:% == per 1 one?(f:%):Boolean == one? rep f -- identity for composition I := per coerce [dn(), dn(), kroneckerDelta()$T]
-- permutations and identities coerce(p:List Integer):% == r:=I^#p --#p = 1 and p.1 = 1 => return r p3:List Integer:=concat [ _ [i for i in 1..#p],_ [#p+abs(i) for i in p]] d:Arity:=dn()^(#p) c:Arity := reduce(_*, map((x:Integer):Arity+->(x>0=>dn();up()), p)$LIST2(Integer, Arity))$List(Arity) r:=per coerce [d, c, reindex(dat(rep r).data, p3)] return r coerce(p:List None):% == per coerce [1, 1, 1] -- twist X := [2, 1]::List Integer::%
-- product elt(f:%,g:%):% == f * g elt(f:%, g:Integer):% == f * [g @ Integer]::List Integer::% elt(f:%, g1:Integer, g2:Integer):% == f * [g1 @ Integer, g2 @ Integer]::List Integer::% elt(f:%, g1:Integer, g2:Integer, g3:Integer):% == f * [g1 @ Integer, g2 @ Integer, g3 @ Integer]::List Integer::% apply(f:%, g:%):% == f * g -- just free monoid product (f:% * g:%):% == -- evaluate scalars if f = 1 then return g if g = 1 then return f if dom(f)=1 and cod(f)=1 then if dom(g)=1 and cod(g)=1 then per coerce [1, 1, coerce(retract(eval f)@K * retract(eval g)@K)] else per (rep(eval f) * rep g) else if dom(g)=1 and cod(g)=1 then per (rep f * rep(eval g)) else per (rep f * rep g)
coerce(x:K):% == 1*x
-- tensor powers (f:% ^ p:Arity):% == r:% := 1 for i in 1..len(p) repeat if color(p,i)=dn() then r:=r*f else r:=r*dagger(f) return r
-- returns arity of leading identities leadI(x:Rep):Arity == xx := x s:Arity:=1 repeat r:=overlap(rep(I),xx) --output("lead r = ", r::OutputForm)$OutputPackage if r.lm=1 and r.mm=rep(I) then s := s * dn() xx:= r.lm else r:=overlap(rep(dagger I), xx) if r.lm=1 and r.mm=rep(I) then s := s * up() xx:= r.lm else break return s
-- returns arity of trailing identities trailI(x:Rep):Arity == xx := x s:Arity:=1 repeat r:=overlap(xx,rep(I)) --output("trail r = ", r::OutputForm)$OutputPackage if r.rm=1 and r.mm=rep(I) then s := dn() * s xx:= r.rm else r:=overlap(xx, rep(dagger I)) if r.rm=1 and r.mm=rep(I) then s := up() * s xx:= r.rm else break return s
-- tensor composition: compose(lnf:Integer,f:Rep, lfn:Integer, lng:Integer, g:Rep, lgn:Integer):T == --output("lnf, lfn, lng, lgn = ", [lnf, lfn, lng, lgn]::List Integer::OutputForm)$OutputPackage ldf := len dom(per f) lcf := len cod(per f) ldg := len dom(per g) lcg := len cod(per g) --output("ldf, lcf, ldg, lcg = ", [ldf, lcf, ldg, lcg]::List Integer::OutputForm)$OutputPackage --output("f, g = ", [f, g]::List Rep::OutputForm)$OutputPackage -- check for permutations (for now just twists) if lcf-lng-lgn=2 then if f=rep(X) then if g=rep(X) then -- compose permutations --output("f/g = I*I", 1::OutputForm)$OutputPackage return dat(rep(I*I)).data else -- twist input p:List Integer := concat [ _ [i for i in 1..lnf], _ [lnf+2, lnf+1], _ [lnf+2+i for i in 1..lfn], _ [lnf+2+lfn+i for i in 1..lcg] ] --print(p::OutputForm)$OutputForm return reindex(dat(g).data, p) else if g=rep(X) then -- twist output p:List Integer := concat [ _ [i for i in 1..ldf], _ [ldf+i for i in 1..lng], _ [ldf+lng+2, ldf+lng+1], _ [ldf+lng+2+i for i in 1..lgn] ] --print(p::OutputForm)$OutputForm return reindex(dat(f).data, p) r:T := contract(lcf-lng-lgn, dat(f).data, ldf+lng+1, dat(g).data, lnf+1) p:List Integer:=concat [ _ [ldf+lgn+i for i in 1..lnf], _ [i for i in 1..ldf], _ [ldf+lnf+lng+i for i in 1..lfn], _ [ldf+i for i in 1..lng], _ [ldf+lnf+lng+lfn+lgn+i for i in 1..lcg], _ [ldf+lng+i for i in 1..lgn] ] --print(p::OutputForm)$OutputForm return reindex(r, p)
parallelize(f:Rep,g:Rep):Record(f1:Rep, g1:Rep, f2:Rep, g2:Rep) == -- parallelize composition f/g = (f1/g1)*(f2/g2) r:Record(f1:Rep, g1:Rep, f2:Rep, g2:Rep):=[1, 1, 1, 1] if cod(per f)~=1 then i:Integer:=1 j:Integer:=1 n:NNI:=1 m:NNI:=1 r.f1 := nthFactor(f, 1)::Rep r.g1 := nthFactor(g, 1)::Rep --print(r::OutputForm)$OutputForm while cod(per r.f1) ~= dom(per r.g1) repeat if len(cod per r.f1) < len(dom per r.g1) then if n < nthExpon(f, i) then n:=n+1 else n:=1 i:=i+1 r.f1 := r.f1 * nthFactor(f, i)::Rep else if len(cod per r.f1) > len(dom per r.g1) then if m < nthExpon(g, j) then m:=m+1 else n:=1 j:=j+1 r.g1 := r.g1 * nthFactor(g, j)::Rep --print([cod(per r.f1)::OutputForm, dom(per r.g1)::OutputForm]::List OutputForm::OutputForm)$OutputForm r.f2 := overlap(r.f1, f).rm r.g2 := overlap(r.g1, g).rm return r
-- f/g : A^n -> A^p = f:A^n -> A^m / g:A^m -> A^p (ff:% / gg:%):% == -- scalars if dom(ff)=1 and cod(ff)=1 and dom(gg)=1 and cod(gg)=1 then return ff*gg fg:=overlap(cod ff,dom gg) if fg.rm~=1 or fg.lm~=1 then -- pass extra f inputs on the left -- pass extra g outputs on the right print(hconcat([message("arity warning: "), _ over(arity(ff)::OutputForm * arity(I^(fg.rm))::OutputForm, _ arity(I^(fg.lm))::OutputForm * arity(gg)::OutputForm) ]))$OutputForm r:=parallelize(rep(ff*I^(fg.rm)), rep(I^(fg.lm)*gg)) -- remove leading and trailing identities nf := leadI r.f1 r.f1 := overlap(rep(I^nf), r.f1).rm ng := leadI r.g1 r.g1 := overlap(rep(I^ng), r.g1).rm --output("nf, ng = ", [nf, ng]::List Arity::OutputForm)$OutputPackage fn := trailI r.f1 f := overlap(r.f1, rep(I^fn)).lm gn := trailI r.g1 g := overlap(r.g1, rep(I^gn)).lm --output("fn, gn = ", [fn, gn]::List Arity::OutputForm)$OutputPackage -- parallel factors guarantees that these are just identities if nf~=1 and nf=ng then return I^nf*(per(r.f2)/per(r.g2)) if fn~=1 and gn~=1 then return (per(f)/per(g))*I^fn return per([nf*dom(per f)*fn, ng*cod(per g)*gn, _ compose(len nf, f, len fn, len ng, g, len gn)]::Rep) * _ (per(r.f2)/per(r.g2))
-- another notation for composition of products (t:Tuple % / x:%):% == t / construct([x])$PrimitiveArray(%)::Tuple(%) (x:% / t:Tuple %):% == construct([x])$PrimitiveArray(%)::Tuple(%) / t (f:Tuple % / g:Tuple %):% == fs:List % := [select(f,i) for i in 0..#f-1] gs:List % := [select(g, i) for i in 0..#g-1] fr:=reduce(elt@(%, %)->%, fs, 1) gr:=reduce(elt@(%, %)->%, gs, 1) fr / gr
(x:K * y:%):% == per coerce [dom y,cod y, x*dat(rep y).data] (x:% * y:K):% == per coerce [dom x, cod x, dat(rep x).data*y] (x:Integer * y:%):% == per coerce [dom y, cod y, x*dat(rep y).data]
-- display operators using basis show(x:%):OutputForm == dom(x)=1 and cod(x)=1 => return (dat(rep x).data)::OutputForm gens:List OutputForm:=[index(i::PositiveInteger)$gener::OutputForm for i in 1..dim] -- input basis inps:List OutputForm := list empty() dx:=dom(x) for i in 1..len(dx) repeat --empty? inps => inps:=gens inps:=concat [[(inps.k * (color(dx,i)=dn()=>gens.j;super(gens.j, message "*"))) _ for j in 1..dim] for k in 1..#inps] -- output basis outs:List OutputForm := list empty() cx:=cod(x) for i in 1..len(cx) repeat --empty? outs => outs:=gens outs:=concat [[(outs.k * (color(cx, i)=dn()=>gens.j;super(gens.j, message "*"))) _ for j in 1..dim] for k in 1..#outs] -- combine input (superscripts) and/or output(subscripts) to form basis symbols bases:List OutputForm if #inps > 0 and #outs > 0 then bases:=concat([[ scripts(message("|"), [i, j]) for i in outs] for j in inps]) else if #inps > 0 then bases:=[super(message("|"), i) for i in inps] else if #outs > 0 then bases:=[sub(message("|"), j) for j in outs] else bases:List OutputForm:= [] -- merge bases with data to form term list terms:=[(k=1 => base;k::OutputForm*base) for base in bases for k in ravel(x) | k~=0] empty? terms => return 0::OutputForm -- combine the terms return reduce(_+, terms)
coerce(x:%):OutputForm == r:OutputForm := empty() for y in factors(rep x) repeat if y.exp = 1 then if size rep x = 1 then r := show per coerce y.gen else r:=r*paren(list show per coerce y.gen) else r:=r*paren(list show per coerce y.gen)^(y.exp::OutputForm) return r
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5869708054946761164-25px005.spad using old system compiler. CLOP abbreviates domain ClosedLinearOperator ------------------------------------------------------------------------ initializing NRLIB CLOP for ClosedLinearOperator compiling into NRLIB CLOP ****** comp fails at level 1 with expression: ****** ((|VectorSpace| K)) ****** level 1 ****** $x:= (VectorSpace K) $m:= $EmptyMode $f:= ((((K # . #1=#) (|gener| # #) (|ClosedLinearOperator| #) (K . #1#) ...)))
>> Apparent user error: cannot compile (VectorSpace K)
Consult the source code above for more details.
Convenient Notation
-- summation macro Σ(f,i, b) == reduce(+, [f*b.i for i in 1..#b])
-- list comprehension macro Ξ(f,i)==[f for i in 1..retract(dimension()$L)]
Example
Q := EXPR INT
(1) |
L := CLOP(OVAR ['x,'y], Q)
ClosedLinearOperator is an unknown constructor and so is unavailable. Did you mean to use -> but type something different instead?
Basis
dim:Integer:=retract dimension()$L
L is not a valid type.
(1,1)-tensor
A:L := Σ( Σ( script(a,[[j], [i]]), i, Dx), j, dx)
L is not a valid type.
scalar
s:= 3::L
L is not a valid type.
Powers
A^p
(2) |
a^p
(3) |
s/A
(4) |
A/s
(5) |
3*A
(6) |
A/3
(7) |
identities
I:L := [1]
L is not a valid type.
Back to the top.
Please leave comments and suggestions.
Thanks
Bill Page