@@ -9,23 +9,23 @@ matrixAction = method();
99matrixAction (Matrix , NCRing, NCRing) := NCRingElement => (M, A, B) -> (
1010 N :=transpose entries M;
1111 f := ncMap(B, A, apply (N, j->sum (length (j), i->j#i* (gens B)#i)));
12- return (f);
12+ f
1313)
1414
1515matrixAction (Matrix , NCRingElement, NCRing) := NCRingElement => (M, p, B) -> (
1616 f := matrixAction(M,ring p, B);
17- return ( f(p));
17+ f(p)
1818)
1919
2020-- Matrix * Tensor also computes the diagonal matrix action on a tensor, but creates the output nc ring automatically
2121Matrix * NCRingElement := (M, f) -> (
2222 n := length entries M;
2323 m := length entries transpose M;
2424 tf := length gens ring f;
25- if (m != tf) then (error (" A " | toString (n) | " x" | toString (m) | " matrix can not act on a tensor over " | toString (tf) | " -dimensional space." );)
25+ if (m != tf) then (error (" a " | toString (n) | " x" | toString (m) | " matrix can not act on a tensor over " | toString (tf) | " -dimensional space." );)
2626 else (
2727 B := wordAlgebra(n, CoefficientRing => (coefficientRing ring f));
28- return ( matrixAction(M, f, B)); )
28+ matrixAction(M, f, B))
2929)
3030
3131-- tensorParametrization takes a tensor T, constructs a ring R with one variable for each word appearing in T
@@ -37,7 +37,7 @@ tensorParametrization(NCRingElement) := opts -> (f) -> (
3737 lm := t / leadMonomial ;
3838 bR := coefficientRing (class f);
3939 bF := baseRing bR;
40- if (not opts.CoefficientRing == = null ) then bF = opts.CoefficientRing ;
40+ if (opts.CoefficientRing =! = null ) then bF = opts.CoefficientRing ;
4141 if (opts.VarWordTable === null ) then (
4242 b := getSymbol (" b" );
4343 varis := apply (lm, i -> b_(wordString i));
@@ -46,29 +46,29 @@ tensorParametrization(NCRingElement) := opts -> (f) -> (
4646 vwtable := opts.VarWordTable;
4747 words := apply (lm, i-> value (wordString i));
4848 R = ring (product (keys vwtable));
49- if (instance (R,QuotientRing )) then error (" Expected free polynomial ring." );
49+ if (instance (R,QuotientRing )) then error (" expected free polynomial ring." );
5050 scan (words, i-> (
5151 if (not isMember (i,values vwtable)) then (
52- print ( " Warning: No variable associated to word " | toString (i));
52+ printerr ( " warning: no variable associated to word " | toString (i));
5353 );
5454 )
5555 );
5656 lc = apply (gens R, i-> inner(f, (vwtable#i)_(ring f)));
5757 );
58- return ( map (bR,R,lc));
58+ map (bR,R,lc)
5959)
6060
6161-- create the non commutative algebra over alphabet given by a list.
6262wordAlgebra = method (Options =>{CoefficientRing => QQ });
6363wordAlgebra (List ) := opts -> (l) -> (
6464 Lt := getSymbol (" Lt" );
6565 myvars := apply (l,i-> (Lt_i));
66- return ( opts.CoefficientRing myvars);
66+ opts.CoefficientRing myvars
6767)
6868
6969-- create the non commutative algebra over alphabet 1..z
7070wordAlgebra (ZZ ) := opts -> (z) -> (
71- return ( wordAlgebra(toList (1..z), CoefficientRing => opts.CoefficientRing ));
71+ wordAlgebra(toList (1..z), CoefficientRing => opts.CoefficientRing )
7272)
7373
7474-- define shuffle products on words, use linExt to extend to NCRingElements. Define operator ** as shuffle product in NCAlgebra
@@ -87,7 +87,7 @@ shuffleHelper(List,List,NCRing) := (w1,w2,R) -> (
8787 i := w1#-1;
8888 j := w2#-1;
8989
90- return ( shuffleHelper(w1,w2l,R)* [j]_R + shuffleHelper(w1l,w2,R)* [i]_R);
90+ shuffleHelper(w1,w2l,R)* [j]_R + shuffleHelper(w1l,w2,R)* [i]_R
9191);
9292
9393shuffleHelper(NCRingElement, List ) := (f,w2) -> linExt(i->shuffleHelper(i,w2,ring f),f);
@@ -96,7 +96,7 @@ shuffleHelper(NCRingElement, NCRingElement) := (f,g) -> (
9696 if (ring f === ring g) then (
9797 return (linExt(i->shuffleHelper(f,i),g));)
9898 else (
99- error " Can not apply shuffle to polynomials from different rings" ;
99+ error " can not apply shuffle to polynomials from different rings" ;
100100 )
101101)
102102
@@ -105,9 +105,9 @@ shuffleHelper(NCRingElement, NCRingElement) := (f,g) -> (
105105shuffle = method ();
106106shuffle (NCRingElement, NCRingElement) := (a, b) -> shuffleHelper(a,b);
107107
108- NCRingElement ** NCRingElement := (f,g) -> (
109- shuffle(f,g)
110- )
108+ NCRingElement ** NCRingElement := shuffle
109+
110+ NCRingElement ⧢ NCRingElement := shuffle
111111
112112-- the antipode of the nc polynomial ring as a Hopf algebra
113113antipode NCRingElement := (f) -> (
@@ -122,16 +122,16 @@ halfshuffleHelper = method();
122122halfshuffleHelper(NCRingElement, List ) := (f,w) -> (
123123 wl := w_(toList (0..length (w)-2));
124124 wr := w_(-1);
125- return ( shuffleHelper(f,wl) * (ring f)_(wr-1) );
125+ shuffleHelper(f,wl) * (ring f)_(wr-1)
126126)
127127
128128halfshuffle = method ();
129129halfshuffle (NCRingElement, NCRingElement) := (f,g) -> (
130130 if (ring f === ring g) then (
131- if (degree f == 0 or degree g == 0 ) then error (" Can not apply halfshuffle to polynomials of degree zero." );
131+ if (degree f == 0 or degree g == 0 ) then error (" can not apply halfshuffle to polynomials of degree zero." );
132132 return (linExt(i->halfshuffleHelper(f,i),g));)
133133 else (
134- error " Can not apply halfshuffle to polynomials from different rings" ;
134+ error " can not apply halfshuffle to polynomials from different rings" ;
135135 )
136136)
137137
@@ -142,16 +142,16 @@ innerHelper = method();
142142innerHelper(List , NCRingElement) := (l,f) -> (
143143 H := coefficientHTable f;
144144 mon := (new Array from l)_(ring f);
145- return ( if (H#?mon) then H#mon else 0 );
145+ if (H#?mon) then H#mon else 0
146146)
147147
148148inner = method ();
149149-- the first argument is to be viewed as an element of the dual space
150150inner(NCRingElement, NCRingElement) := (fv,f) -> (
151- return ( linExt(w->innerHelper(w,f),fv));
151+ linExt(w->innerHelper(w,f),fv)
152152)
153153
154- NCRingElement @ NCRingElement := (f,m) -> inner(f,m);
154+ NCRingElement @ NCRingElement := inner
155155
156156
157157
@@ -199,15 +199,16 @@ adjointWord (NCRingElement, NCPolynomialRing, List) := (f, A, P) -> (
199199
200200 -- Check that number of letters in the given NCRing is enough to compute the image of the word
201201 if d>length (gens A) then (
202- error (" Number of generators of the NCRing lower than dimension of the polynomial ring" )
202+ error (" number of generators of the NCRing lower than dimension of the polynomial ring" )
203203 );
204- if not (length (P) == length (gens ring f)) then error (" The polynomial transformation does not map to the space underlying the input word." );
204+ if not (length (P) == length (gens ring f)) then error (" the polynomial transformation does not map to the space underlying the input word." );
205205
206206 if not all (apply (P, p->part (0,p)), q->q==0) then (
207- error (" The image of 0 under the polynomial map is not 0" );
207+ error (" the image of 0 under the polynomial map is not 0" );
208208 );
209209 if (f == 0 _(ring f)) then return 0 _A;
210- return (linExt(w->adjointWordHelper(w,A,P), f));
210+
211+ linExt(w->adjointWordHelper(w,A,P), f)
211212)
212213
213214
@@ -223,7 +224,8 @@ nextLyndonWord(Array,ZZ,ZZ) := Array => (ar,d,k) -> (
223224 nl = nl_{0..length (nl)-2};
224225 );
225226 if (nl != {d}) then nl = nl + toList (((length (nl)-1):0) | (1:1));
226- return (new Array from nl)
227+
228+ new Array from nl
227229);
228230
229231-- lyndonWords(d,k) returns a list of all Lyndon words of length at most k in d letters
@@ -236,7 +238,8 @@ lyndonWords (ZZ,ZZ) := (d,k) -> (
236238 while (l_(-1) != [d]) do (
237239 l = l | {nextLyndonWord(l_(-1),d,k)};
238240 );
239- return (l);
241+
242+ l
240243)
241244
242245-- lie(a,b) returns the lie bracket of a and b
@@ -250,7 +253,8 @@ isLyndon Array := (w) -> (
250253 l := toList w;
251254 out := true ;
252255 scan (1..length (l)-1, i->( if (out==true ) then out = (l < l_{i..(length (l)-1)}) ) );
253- return (out);
256+
257+ out
254258);
255259
256260-- lyndonFact(l) computes the standard decomposition of l
@@ -262,7 +266,8 @@ lyndonDecomposition Array := (w) -> (
262266 cand := select (ls,i-> isLyndon(i_1));
263267 cand = cand_0;
264268 if (isLyndon(cand#0)) then return cand;
265- return (lyndonDecomposition(cand#0) | {cand#1})
269+
270+ lyndonDecomposition(cand#0) | {cand#1}
266271)
267272
268273
@@ -273,15 +278,15 @@ lieBasis(Array, NCPolynomialRing) := (w,R) -> (
273278 if (length (w) == 0 ) then error (" lieBasis expected a non-empty list as input." );
274279 if (length (w) == 1 ) then return R_(w_(-1) - 1 );
275280 fact := apply (lyndonDecomposition(w),i-> lieBasis(i,R));
276- return ( lie(fact_0,fact_1) )
281+ lie(fact_0,fact_1)
277282)
278283
279284lieBasis(List , NCPolynomialRing) := (l, R) -> lieBasis (new Array from l, R);
280285
281286
282287
283288expTerm = (tl,l) -> (
284- return ( 1/(length (l))!)* product (l,i->(tl_i) )
289+ 1 /(length (l))!)* product (l,i->(tl_i)
285290)
286291
287292-- Given a tensor p with constant term 0, tensorExp(p,k) returns the k-th level component of exp(p)
@@ -292,11 +297,12 @@ tensorExp (NCRingElement, ZZ) := (p,k) -> (
292297 s := {1} | toList apply (1..k, i-> sum (select (terms p, j->((degree j) == i))));
293298 comp := unique apply (compositions k, i->delete (0,i));
294299 t := sum (apply (comp, i-> expTerm(s,i)));
295- return (t);
300+
301+ t
296302)
297303
298304logTerm = (tl,l) -> (
299- return ( 1/(length (l)))* product (l,i->(tl_i) )
305+ 1 /(length (l)))* product (l,i->(tl_i)
300306)
301307
302308-- Given a tensor p with constant term 1, tensorLog(p,k) returns the k-th level component of log(p)
@@ -307,7 +313,8 @@ tensorLog (NCRingElement, ZZ) := (p,k) -> (
307313 s := {1} | toList apply (1..k, i-> sum (select (terms lp, j->((degree j) == i))));
308314 comp := unique apply (compositions k, i->delete (0,i));
309315 t := - sum (apply (comp, i-> logTerm(s,i)));
310- return (t);
316+
317+ t
311318)
312319
313320lyndonShuffleHelper = method ();
@@ -330,7 +337,7 @@ lyndonShuffleHelper(List,Ring,NCRing) := (l,R,A) -> ( -- R must be a suitable ri
330337)
331338
332339lyndonShuffleHelper(NCRingElement,Ring ) := (f,R) -> (
333- return ( linExt(i->lyndonShuffleHelper(i, R, ring f),f,CoefficientRing => R) )
340+ linExt(i->lyndonShuffleHelper(i, R, ring f),f,CoefficientRing => R)
334341)
335342
336343lyndonShuffle = method ();
@@ -344,7 +351,7 @@ lyndonShuffle(NCRingElement) := (f) -> ( -- rewrites a tensor as a shuffle polyn
344351 pol := lyndonShuffleHelper(f,R);
345352 polh := standardForm pol;
346353 polh = applyKeys (polh, i-> applyKeys (i,j-> last baseName R_j));
347- return ( polh);
354+ polh
348355)
349356
350357
0 commit comments