z=0; -- Goal: reduce memory management by working through the words as a tree run "date"; needsPackage("LieTypes"); load "LieAlgebraRepresentations.v2.3.m2"; load "SpinRepresentations.v1.7.m2"; n=5; k=7; lambda1={5,0,0,0,0}; B = so2nBasis(n); sB = spinBasis(n,QQ); Bstar = so2nDualBasis(n); BstarPerm = flatten apply(#Bstar, i -> flatten select(#B, j -> Bstar_i == 1/(4*(n-1))*B_j)); splusBDense = apply(sB, M -> M_(apply(2^(n-1), i -> i))^(apply(2^(n-1), i -> i))); splusB = apply(splusBDense, M -> sparseRep(M)); so2nRaisingOperators = so2nPositiveRoots(n); PhiminusIndices = select(#B, i -> i >=n and not member(B_i,so2nRaisingOperators)); NegativeRoots = so2nNegativeRootsDbasis(n); EWB = evenWedgeBasis(n); snk = sort subsets(apply(2^(n-1), i -> i),k); ZtoW = new HashTable from apply(#snk, i -> {i,snk_i}); WtoZ = new HashTable from apply(#snk, i -> {snk_i,i}); K=QQ; ringSubscripts = apply(snk, s -> apply(s, i -> EWB_i)); R=K[apply(ringSubscripts, i -> yy_i),MonomialOrder=>Lex]; H = new HashTable from apply(numgens R, i-> {R_i,i}); Splusweights = apply(2^(n-1), j -> apply(n, i -> splusBDense_i_(j,j))); Wedgekweights = apply(snk, s -> sum apply(s, j -> Splusweights_j)); sparseMatrixToImageLists = (M,R) -> ( apply(numgens R, i -> sum delete(null,apply(M, x -> if x#0#1==i then (x#1)*(R_(x#0#0))))) ); -- Recreate LoweringOperators1 with a little less work than before -- (We only create WedgekSplusBasis for 8 elements instead of 40) LoweringOperators1 = apply(#PhiminusIndices, i -> if member(i,{0, 1, 3, 6, 10, 11, 12, 13}) then sparseMatrixToImageLists(XactionOnWedgek(splusB_(PhiminusIndices_i),k,ZtoW,WtoZ),R)); monomialFactors = (m) -> ( e:=flatten exponents(m); A:={}; for i from 0 to #e-1 do ( for j from 0 to e_i-1 do ( A=append(A,i) ) ); return sort A ); actOnMonomial = (X,m) -> ( if first(degree(m))!=2 then error "Only implemented for degree 2"; mf:=monomialFactors(m); (X#(mf_0))*(R_(mf_1)) + (R_(mf_0))*(X#(mf_1)) ); act = memoize((X,f) -> ( if f==0_(ring f) then return f; T:=terms(f); sum apply(T, t -> leadCoefficient(t)*actOnMonomial(X,leadMonomial(t))) )); so2n = simpleLieAlgebra("D",n); WD = weightDiagram(irreducibleLieAlgebraModule(lambda1,so2n)); -- Load v1 and v2 load "Sym2 V1 highest weight vector for 5w1.m2"; load "Sym2 V2 highest weight vector for 5w1.m2"; wt = (f) -> ( e:=flatten exponents leadMonomial f; LtoD(sum apply(#e, i -> (e_i)*(Wedgekweights_i))) ); applyWord = (w,v,actInstance,LoweringOperators) -> ( if w=={} then return v; x:=reverse(w); u:=v; for i from 0 to #x-1 do ( u = actInstance(LoweringOperators_(x_i),u); if u==0 then return u; ); return u ); load "MyBasisWords.m2"; -- This is the corrected version from Feb 21 2023 BR7Span = matrix {{0/1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 1/2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}; g7CCSpan=matrix {{0, 0, 0, 0, -3/5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1/5, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 3/4, 1, 0, 0, 0, 0, 0}, {30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, {0,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Span); FFCurvet = map(Qt,R,apply(numgens R, i -> det(FCurvetSpan_(snk_i)))); -- I is the set of weights in WD where there are nonzero degree 2 monomials -- Computed in EvaluationMatrices.5.m2 -- This is for all four examples (not just g7CC) I = {{-5, 3, 0, 0, 0}, {-4, 1, 0, -1, 1}, {-4, 1, 0, 1, -1}, {-4, 1, 1, 0, 0}, {-4, 4, 1, -1, -1}, {-4, 5, -1, 0, 0}, {-3, -2, 2, 0, 0}, {-3, -1, 0, 1, 1}, {-3, 0, -2, 2, 2}, {-3, 2, 1, -2, 0}, {-3, 2, 1, -1, 1}, {-3, 2, 1, 0, -2}, {-3, 2, 1, 1, -1}, {-3, 2, 2, -2, -2}, {-3, 3, -1, -1, 1}, {-3, 3, -1, 0, 2}, {-3, 3, -1, 1, -1}, {-3, 3, -1, 2, 0}, {-2, -1, 2, 1, -1}, {-2, -1, 3, -2, -2}, {-2, -1, 3, -1, -1}, {-2, -1, 3, 0, 0}, {-2, 0, 0, 2, 0}, {-2, 0, 1, -3, 1}, {-2, 0, 1, -2, 2}, {-2, 0, 1, -1, -1}, {-2, 0, 1, 0, 0}, {-2, 0, 1, 1, -3}, {-2, 0, 1, 1, 1}, {-2, 0, 1, 2, -2}, {-2, 0, 2, -2, 0}, {-2, 0, 2, 0, -2}, {-2, 1, -1, -2, 2}, {-2, 1, -1, -1, 3}, {-2, 1, -1, 0, 0}, {-2, 1, -1, 1, 1}, {-2, 1, -1, 2, -2}, {-2, 1, -1, 2, 2}, {-2, 1, -1, 3, -1}, {-2, 1, 0, -1, 1}, {-2, 1, 0, 1, -1}, {-2, 1, 1, -1, -1}, {-2, 1, 1, 1, -3}, {-2, 2, -3, 1, 1}, {-2, 2, -3, 2, 2}, {-2, 2, -3, 3, 3}, {-2, 2, -2, 0, 2}, {-2, 2, -1, 0, 0}, {-2, 2, 0, 0, -2}, {-2, 5, -3, 0, 0}, {-1, -3, 3, -1, 1}, {-1, -3, 3, 1, -1}, {-1, -3, 4, -1, -1}, {-1, -2, 1, -1, 1}, {-1, -2, 1, 0, 2}, {-1, -2, 1, 1, -1}, {-1, -2, 1, 2, 0}, {-1, -2, 2, -2, 2}, {-1, -2, 2, 0, 0}, {-1, -2, 2, 2, -2}, {-1, -2, 3, -2, 0}, {-1, -2, 3, 0, -2}, {-1, -1, -1, 0, 2}, {-1, -1, -1, 1, 3}, {-1, -1, -1, 2, 0}, {-1, -1, -1, 3, 1}, {-1, -1, 0, 1, 1}, {-1, -1, 1, -1, 1}, {-1, -1, 1, 1, -1}, {-1, -1, 2, -1, -1}, {-1, -1, 2, 1, -3}, {-1, -1, 3, 0, -2}, {-1, 0, -4, 4, 4}, {-1, 0, -3, 2, 4}, {-1, 0, -3, 4, 2}, {-1, 0, -1, 0, 2}, {-1, 0, -1, 2, 0}, {-1, 0, 0, 0, 0}, {-1, 0, 0, 2, -2}, {-1, 0, 1, 0, -2}, {-1, 0, 1, 1, -1}, {-1, 0, 2, -1, -1}, {-1, 0, 2, 1, -3}, {-1, 0, 4, -4, -4}, {-1, 0, 4, -3, -3}, {-1, 1, -2, 1, 1}, {-1, 1, -1, 1, -1}, {-1, 1, 0, 0, 0}, {-1, 1, 1, -2, 0}, {-1, 1, 1, 0, -2}, {-1, 1, 2, -4, 0}, {-1, 1, 2, -3, -3}, {-1, 1, 2, -2, -2}, {-1, 1, 2, -1, -1}, {-1, 1, 2, 0, -4}, {-1, 1, 3, -4, -2}, {-1, 1, 3, -2, -4}, {-1, 2, -1, -1, 1}, {-1, 2, 0, -3, 1}, {-1, 2, 0, -2, -2}, {-1, 2, 0, -2, 2}, {-1, 2, 0, -1, -1}, {-1, 2, 0, 0, 0}, {-1, 2, 0, 1, -3}, {-1, 2, 0, 2, -2}, {-1, 3, -3, 0, 2}, {-1, 3, -3, 2, 0}, {-1, 3, -2, -2, 2}, {-1, 3, -2, -1, -1}, {-1, 3, -2, 0, 0}, {-1, 3, -2, 1, 1}, {-1, 3, -2, 2, -2}, {-1, 4, -4, 0, 0}, {-1, 4, -4, 1, 1}, {0, -4, 3, 0, 0}, {0, -3, 1, 1, 1}, {0, -3, 2, -1, 1}, {0, -3, 2, 1, -1}, {0, -3, 3, -1, -1}, {0, -3, 4, 0, -2}, {0, -2, 0, 0, 2}, {0, -2, 0, 2, 0}, {0, -2, 1, 0, 0}, {0, -2, 1, 2, -2}, {0, -2, 2, 0, -2}, {0, -2, 2, 1, -1}, {0, -2, 3, -1, -1}, {0, -2, 3, 1, -3}, {0, -2, 4, -3, -1}, {0, -2, 4, -1, -3}, {0, -1, -1, 1, 1}, {0, -1, 0, 1, -1}, {0, -1, 1, 0, 0}, {0, -1, 2, -4, 2}, {0, -1, 2, -3, -1}, {0, -1, 2, -2, 0}, {0, -1, 2, -1, -3}, {0, -1, 2, -1, 1}, {0, -1, 2, 0, -2}, {0, -1, 2, 1, -1}, {0, -1, 2, 2, -4}, {0, -1, 3, -4, 0}, {0, -1, 3, -2, -2}, {0, -1, 3, 0, -4}, {0, 0, -2, 2, 0}, {0, 0, -1, 1, 1}, {0, 0, 0, -5, 5}, {0, 0, 0, -3, 3}, {0, 0, 0, -2, 0}, {0, 0, 0, -1, 1}, {0, 0, 0, 0, -2}, {0, 0, 0, 0, 2}, {0, 0, 0, 1, -1}, {0, 0, 0, 2, 0}, {0, 0, 0, 3, -3}, {0, 0, 1, -1, -1}, {0, 0, 2, 0, -2}, {0, 1, -3, 0, 4}, {0, 1, -3, 2, 2}, {0, 1, -3, 4, 0}, {0, 1, -2, -2, 4}, {0, 1, -2, -1, 1}, {0, 1, -2, 0, 2}, {0, 1, -2, 1, -1}, {0, 1, -2, 1, 3}, {0, 1, -2, 2, 0}, {0, 1, -2, 3, 1}, {0, 1, -2, 4, -2}, {0, 1, -1, 0, 0}, {0, 1, 1, -1, -1}, {0, 2, -4, 1, 3}, {0, 2, -4, 3, 1}, {0, 2, 0, -2, 0}, {1, -4, 2, 0, 0}, {1, -4, 3, 1, -1}, {1, -4, 4, -1, -1}, {1, -4, 4, 0, 0}, {1, -3, 0, 1, 1}, {1, -3, 1, 1, -1}, {1, -3, 2, -2, 2}, {1, -3, 2, -1, -1}, {1, -3, 2, 0, 0}, {1, -3, 2, 1, 1}, {1, -3, 2, 2, -2}, {1, -3, 3, -2, 0}, {1, -3, 3, 0, -2}, {1, -2, -1, 2, 0}, {1, -2, 0, -2, 2}, {1, -2, 0, -1, 3}, {1, -2, 0, 0, 0}, {1, -2, 0, 1, 1}, {1, -2, 0, 2, -2}, {1, -2, 0, 2, 2}, {1, -2, 0, 3, -1}, {1, -2, 1, -1, 1}, {1, -2, 1, 1, -1}, {1, -2, 2, -1, -1}, {1, -2, 3, 0, -2}, {1, -1, -3, 2, 4}, {1, -1, -3, 4, 2}, {1, -1, -2, 0, 4}, {1, -1, -2, 1, 1}, {1, -1, -2, 2, 2}, {1, -1, -2, 3, 3}, {1, -1, -2, 4, 0}, {1, -1, -1, 0, 2}, {1, -1, 0, 0, 0}, {1, -1, 2, -1, -1}, {1, 0, -4, 3, 3}, {1, 0, -4, 4, 4}, {1, 0, -2, 1, 1}, {1, 0, 0, 0, 0}, {1, 0, 1, -2, 0}, {1, 0, 3, -4, -2}, {1, 0, 3, -2, -4}, {1, 0, 4, -4, -4}, {1, 1, -1, -1, 1}, {1, 1, 1, -3, -1}, {1, 1, 1, -2, 0}, {1, 1, 1, -1, -3}, {1, 1, 1, 0, -2}, {1, 2, -2, -2, 2}, {1, 2, -2, 0, 0}, {1, 2, -2, 2, -2}, {1, 2, -1, -2, 0}, {1, 2, -1, -1, 1}, {1, 2, -1, 0, -2}, {1, 2, -1, 1, -1}, {1, 3, -3, -1, 1}, {1, 3, -3, 1, -1}, {2, -5, 3, 0, 0}, {2, -4, 1, 1, 1}, {2, -4, 2, -1, 1}, {2, -4, 2, 1, -1}, {2, -3, 0, 0, 2}, {2, -3, 1, 0, 0}, {2, -3, 3, -1, -1}, {2, -2, -1, 1, 1}, {2, -2, 1, 0, 0}, {2, -2, 2, -2, 0}, {2, -2, 3, -3, -3}, {2, -2, 3, -2, -2}, {2, -2, 3, -1, -1}, {2, -1, 0, -1, 1}, {2, -1, 1, -3, 1}, {2, -1, 1, -2, -2}, {2, -1, 1, -2, 2}, {2, -1, 1, -1, -1}, {2, -1, 1, 0, 0}, {2, -1, 1, 1, -3}, {2, -1, 1, 2, -2}, {2, 0, -2, 0, 2}, {2, 0, -2, 2, 0}, {2, 0, -1, -2, 2}, {2, 0, -1, -1, -1}, {2, 0, -1, -1, 3}, {2, 0, -1, 0, 0}, {2, 0, -1, 1, 1}, {2, 0, -1, 2, -2}, {2, 0, -1, 3, -1}, {2, 1, -3, 0, 0}, {2, 1, -3, 1, 1}, {2, 1, -3, 2, 2}, {3, -4, 0, 1, 1}, {3, -4, 2, 0, 0}, {3, -3, 1, -2, 0}, {3, -3, 1, -1, 1}, {3, -3, 1, 0, -2}, {3, -3, 1, 1, -1}, {3, -2, -2, 2, 2}, {3, -2, -1, -1, 1}, {3, -2, -1, 0, 2}, {3, -2, -1, 1, -1}, {3, -2, -1, 2, 0}, {3, 0, 2, -2, -2}, {3, 1, 0, -1, -1}, {3, 2, -2, 0, 0}, {4, -5, 1, 0, 0}, {4, -4, -1, 1, 1}, {4, -1, -1, 0, 0}, {4, -1, 0, -1, 1}, {4, -1, 0, 1, -1}, {5, -3, 0, 0, 0}}; T = join(terms(v1),terms(v2)); T = apply(T, t -> leadMonomial(t)); T = sort unique T; load "5w1WordsByWeight.m2"; weightOfWord = (w,WordsByWeight) -> ( first select(keys(WordsByWeight),k -> member(w,WordsByWeight#k))); WordWeight = new HashTable from apply(MyBasisWords, w -> {w,weightOfWord(w,WordsByWeight)}); myTerms = (f) -> ( if f==0 then 0 else #(terms f) ); GroupedWords = apply({0, 1, 3, 6, 10, 11, 12, 13}, x -> {{x},select(MyBasisWords, w -> #w>0 and last(w)==x)}); GroupedWords = prepend({ {}, {{}} },GroupedWords); GroupedWords = new HashTable from GroupedWords; for i from 12*z to min({#T-1,12*z+11}) do ( stri = toString(i); if #stri==1 then stri = concatenate("00",toString(i)); if #stri==2 then stri = concatenate("0",toString(i)); fnBR7 = openOut concatenate("BR7valuesByTerm.",stri,".out"); fng7CC = openOut concatenate("g7CCvaluesByTerm.",stri,".out"); fnFCurve0 = openOut concatenate("FCurve0valuesByTerm.",stri,".out"); fnFCurvet = openOut concatenate("FCurvetvaluesByTerm.",stri,".out"); act = memoize((X,f) -> ( if f==0_(ring f) then return f; T:=terms(f); sum apply(T, t -> leadCoefficient(t)*actOnMonomial(X,leadMonomial(t))) )); MBWtg7cc= new MutableHashTable from apply(MyBasisWords, w -> {w,0}); MBWtBR7=new MutableHashTable from apply(MyBasisWords, w -> {w,0}); MBWtFCurve0=new MutableHashTable from apply(MyBasisWords, w -> {w,0}); MBWtFCurvet=new MutableHashTable from apply(MyBasisWords, w -> {w,0}); for k in keys(GroupedWords) do ( print concatenate("k=",toString(k)) << endl; act = memoize((X,f) -> ( if f==0_(ring f) then return f; T:=terms(f); sum apply(T, t -> leadCoefficient(t)*actOnMonomial(X,leadMonomial(t))) )); GroupkWords = GroupedWords#k; print concatenate("#words: ",toString(#GroupkWords)) << endl; for j from 0 to #GroupkWords-1 do ( w=GroupkWords_j; g=0; if member(WordWeight#w,I) then ( g=applyWord(w,T_i,act,LoweringOperators1) ); MBWtg7cc#w = Fg7CC(g); MBWtBR7#w = FBR7(g); MBWtFCurve0#w = FFCurve0(g); MBWtFCurvet#w = FFCurvet(g); print concatenate(" ",toString(w), " finished") << endl; ); ); g7CCvalues = apply(MyBasisWords, w -> MBWtg7cc#w); BR7values = apply(MyBasisWords, w -> MBWtBR7#w); FCurve0values = apply(MyBasisWords, w -> MBWtFCurve0#w); FCurvetvalues = apply(MyBasisWords, w -> MBWtFCurvet#w); fng7CC << toString({i,g7CCvalues}) << "," << endl; fnBR7 << toString({i,BR7values}) << "," << endl; fnFCurve0 << toString({i,FCurve0values}) << "," << endl; fnFCurvet << toString({i,FCurvetvalues}) << "," << endl; print concatenate("Term ",toString(i)," complete") << endl; close fng7CC; close fnBR7; close fnFCurve0; close fnFCurvet; run "date"; ); run "date"; quit