Skip to content

Commit

Permalink
cartan(::Symbol,...) accepts a cartanType
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichel7 committed Oct 2, 2024
1 parent 11f0896 commit c769746
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 55 deletions.
7 changes: 3 additions & 4 deletions src/InitChevie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ const needcartantype=Set([:Invariants,
:WeightInfo,
:CartanMat])

const debug=Ref(false) # time each call
debug::Bool=false # time each call

"`getchev(t::TypeIrred,f::Symbol,extra...)` get `CHEVIE[field(t)][f](extra...)`"
function getchev(t::TypeIrred,f::Symbol,extra...)
n,args...=field(t)
# println("d=$d f=$f extra=$extra")
o=chevieget(n,f)
if o isa Function
if haskey(t,:orbit) t=t.orbit[1] end
if debug[]
if debug
if haskey(t,:cartanType) && f in needcartantype
println("$n.$f(",(args...,extra...,t.cartanType),")")
@time o(args...,extra...,t.cartanType)
Expand All @@ -102,10 +103,8 @@ if debug[]
end
else
if haskey(t,:cartanType) && f in needcartantype
# println("$f(",(args...,extra...,t.cartanType),")")
o(args...,extra...,t.cartanType)
else
# println("$f(",(args...,extra...),")")
o(args...,extra...)
end
end
Expand Down
21 changes: 9 additions & 12 deletions src/PermRoot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function asreflection(m::AbstractMatrix)
if !isnothing(r) asreflection(m,rr[r,:]) end
end
#------------------------------------------------------------------------
@GapObj struct TypeIrred end
@GapObj mutable struct TypeIrred end

Base.copy(t::TypeIrred)=TypeIrred(copy(t.prop))

Expand Down Expand Up @@ -642,18 +642,15 @@ end

function cartan(t::TypeIrred;permute=false)
if t.series==:ST return improve_type(toM(getchev(t,:CartanMat))) end
C=cartan(t.series,rank(t),haskey(t,:bond) ? t.bond : 0)
if haskey(t,:cartanType) ct=t.cartanType
T=promote_type(typeof(ct),eltype(C))
if T!=eltype(C) C=convert.(T,C) end
if t.series in (:B,:G,:I) C[2,1]*=-C[1,2]//ct; C[1,2]=-ct
elseif t.series==:F C[3,2]*=-C[2,3]//ct; C[2,3]=-ct
end
end
if indices(t)!=1:rank(t) && permute
C=C[sortperm(indices(t)),sortperm(indices(t))]
C=haskey(t,:bond) ? haskey(t,:cartanType) ?
cartan(t.series,rank(t),t.bond,t.cartanType) :
cartan(t.series,rank(t),t.bond) :
haskey(t,:cartanType) ? cartan(t.series,rank(t),t.cartanType) :
cartan(t.series,rank(t))
if permute && indices(t)!=1:rank(t)
p=sortperm(indices(t));C=C[p,p]
end
improve_type(C)
C
end

cartan(W::PermRootGroup,I)=[cartan(W,i,j) for i in I, j in I]
Expand Down
55 changes: 35 additions & 20 deletions src/Weyl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,15 @@ cartanmats[:a]=cartanmats[:A]=function(r)
end
m
end
cartanmats[:b]=cartanmats[:B]=function(r)
cartanmats[:b]=cartanmats[:B]=function(r,cartanType=2)
m=cartanmats[:A](r)
if r>1 m[1,2]=-2 end
if r>1
if cartanType==2 m[1,2]=-2
else m=typeof(cartanType//1).(m);m[1,2]=-cartanType;m[2,1]=-2//cartanType
end
end
m
end
cartanmats[:isym]=cartanmats[:Isym]=function(b)
[2 -E(2*b)-E(2*b,-1);-E(2*b)-E(2*b,-1) 2]
end
cartanmats[:bsym]=cartanmats[:Bsym]=function(r)
m=Cyc.(cartanmats[:A](r))
m[1:2,1:2]=cartanmats[:Isym](4)
Expand All @@ -261,10 +262,12 @@ cartanmats[:e]=cartanmats[:E]=function(r)
u=1:min(r,4); m[u,u]=[2 0 -1 0; 0 2 0 -1;-1 0 2 -1;0 -1 -1 2][u,u]
m
end
cartanmats[:f]=cartanmats[:F]=function(r)
cartanmats[:f]=cartanmats[:F]=function(r,cartanType=1)
if r!=4 error("type :F is defined only for rank 4") end
m=cartanmats[:A](r)
m[3,2]=-2
if cartanType==1 m[3,2]=-2
else m=typeof(cartanType//1).(m);m[3,2]=-2//cartanType;m[2,3]=-cartanType
end
m
end
cartanmats[:fsym]=cartanmats[:Fsym]=function(r)
Expand All @@ -273,10 +276,12 @@ cartanmats[:fsym]=cartanmats[:Fsym]=function(r)
m[3,2]=m[2,3]=-root(2)
m
end
cartanmats[:g]=cartanmats[:G]=function(r)
cartanmats[:g]=cartanmats[:G]=function(r,cartanType=1)
if r!=2 error("type :G is defined only for rank 2") end
m=cartanmats[:A](r)
m[2,1]=-3
if cartanType==1 m[2,1]=-3
else m=typeof(cartanType//1).(m);m[1,2]=-cartanType;m[2,1]=-3//cartanType
end
m
end
cartanmats[:gsym]=cartanmats[:Gsym]=r->cartanmats[:Isym](6)
Expand All @@ -286,9 +291,18 @@ cartanmats[:h]=cartanmats[:H]=function(r)
m[1:2,1:2]=cartanmats[:Isym](5)
m
end
cartanmats[:i]=cartanmats[:I]=function(b)
res=b%2==0 ? [2 (b==2 ? 0 : -1);-2-E(b)-E(b,-1) 2] : cartanmats[:Isym](b)
(b<5 || b==6) ? Int.(res) : res
cartanmats[:isym]=cartanmats[:Isym]=function(bond)
c=improve_type(-E(2*bond)-E(2*bond,-1))
[2 c;c 2]
end
cartanmats[:i]=cartanmats[:I]=function(r,bond,cartanType=1)
if r!=2 error("$r should be 2") end
if isodd(bond) cartanmats[:Isym](bond)
elseif bond==2
[2 0;0 2]
else
improve_type([2 -cartanType;(-2-E(bond)-E(bond,-1))//cartanType 2])
end
end
"""
`cartan(type, rank [,bond])`
Expand Down Expand Up @@ -320,8 +334,8 @@ julia> cartan(:Bsym,2)
-√2 2
```
"""
function PermRoot.cartan(t::Symbol,r::Integer,b::Integer=0)
if haskey(cartanmats,t) b==0 ? cartanmats[t](r) : cartanmats[t](b)
function PermRoot.cartan(t::Symbol,r::Integer,args::Number...)
if haskey(cartanmats,t) cartanmats[t](r,args...)
else error("Unknown Cartan type $(repr(t)). Known types are:\n",
join(sort(repr.(collect(keys(cartanmats)))),", "))
end
Expand Down Expand Up @@ -405,10 +419,10 @@ function type_fincox_cartan(m::AbstractMatrix)
if bond==1 t.series=:A
elseif bond==2 t.series=:B
if l(1)==-1 reverse!(s) end # B2 preferred to C2
t.cartanType=-l(1)
t.cartanType=improve_type(-l(1))
elseif bond==3 t.series=:G
if r(1)==-1 reverse!(s) end
t.cartanType=-l(1)
t.cartanType=improve_type(-l(1))
else n=conductor(bond)
if r(1)==-1 reverse!(s) end
if bond==2+E(n)+E(n,-1) bond=n else bond=2n end
Expand All @@ -422,17 +436,18 @@ function type_fincox_cartan(m::AbstractMatrix)
if l(2)*r(2)==1 t.series=:A
else t.series=:F
if r(2)==-1 reverse!(s) end
t.cartanType=-l(2)
t.cartanType=improve_type(-l(2))
end
else n=conductor(l(1)*r(1))
if n==5 t.series=:H
else t.series=:B
t.cartanType=-l(1)
t.cartanType=improve_type(-l(1))
end
end
end
t.indices=s::Vector{Int}
end
return t
# println("t=$t")
# println("indices=",t.indices]," cartan=",cartan(t)," m=$m")
if cartan(t,permute=true)==m return t end # countercheck
Expand Down Expand Up @@ -797,8 +812,8 @@ julia> reflrep(W)
[1 3; 0 -1]
```
"""
CoxGroups.coxeter_group(t::Symbol,r::Int=0,b::Int=0;sc=false)=iszero(r) ? coxgroup() :
sc ? rootdatum(permutedims(cartan(t,r,b)),Matrix{Int}(I,r,r)) : rootdatum(cartan(t,r,b))
CoxGroups.coxeter_group(t::Symbol,r::Int=0,b::Int...;sc=false)=iszero(r) ? coxgroup() :
sc ? rootdatum(permutedims(cartan(t,r,b...)),Matrix{Int}(I,r,r)) : rootdatum(cartan(t,r,b...))

"""
`rootdatum(C::AbstractMatrix)` adjoint root datum from Cartan matrix `C`.
Expand Down
2 changes: 1 addition & 1 deletion src/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JULIA=1.10.4
JULIA=1.10.5
test: *.jl
~/julia-$(JULIA)/bin/julia ../tools/gentest.jl *.jl
mv runtests.jl ../test
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ end
@test mytest("Symbols.jl","defectsymbol([[1,5,6],[1,2]])","1")
@test mytest("Symbols.jl","degree_fegsymbol([[1,5,6],[1,2]])","88")
@test mytest("Symbols.jl","valuation_fegsymbol([[1,5,6],[1,2]])","16")
@test mytest("Symbols.jl","stringsymbol.(rio(),symbols(3,3,0))","12-element Vector{String}:\n \"(1+)\"\n \"(1ζ₃)\"\n \"(1ζ₃²)\"\n \"(01,12,02)\"\n \"(01,02,12)\"\n \"(012,012,123)\"\n \"(0,1,2)\"\n \"(0,2,1)\"\n \"(01,01,13)\"\n \"(0,0,3)\"\n \"(012,,)\"\n \"(012,012,)\"")
@test mytest("Symbols.jl","stringsymbol.(symbols(3,2))","14-element Vector{String}:\n \"(12,0,0)\"\n \"(02,1,0)\"\n \"(02,0,1)\"\n \"(012,12,01)\"\n \"(01,1,1)\"\n \"(012,01,12)\"\n \"(2,,)\"\n \"(01,2,0)\"\n \"(01,0,2)\"\n \"(1,012,012)\"\n \"(,02,01)\"\n \"(,01,02)\"\n \"(0,,012)\"\n \"(0,012,)\"")
@test mytest("Symbols.jl","stringsymbol.(symbols(3,3,0))","12-element Vector{String}:\n \"(1+)\"\n \"(1E(3))\"\n \"(1E(3,2))\"\n \"(01,12,02)\"\n \"(01,02,12)\"\n \"(012,012,123)\"\n \"(0,1,2)\"\n \"(0,2,1)\"\n \"(01,01,13)\"\n \"(0,0,3)\"\n \"(012,,)\"\n \"(012,012,)\"")
@test mytest("Symbols.jl","fegsymbol([[1,5,6],[1,2]])","q¹⁶Φ₅Φ₇Φ₈Φ₉Φ₁₀Φ₁₁Φ₁₄Φ₁₆Φ₁₈Φ₂₀Φ₂₂")
Expand Down
35 changes: 17 additions & 18 deletions tools/timings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using Chairmarks

#julia> @b test_w0(6)
#1.10.3 11.648 ms (182389 allocs: 12.981 MiB)
#1.11.α2 11.671 ms (237323 allocs: 13.295 MiB)
#1.11.rc 11.671 ms (237323 allocs: 13.295 MiB)
function test_w0(n)
W=coxsym(n+1)
Tbasis(hecke(W,Pol()))(longest(W))^2
Expand All @@ -22,7 +22,7 @@ end;

#julia> @b CyclotomicNumbers.testmat(9)^2 seconds=2
#1.10.3 42.501 ms (286780 allocs: 49.168 MiB)
#1.11.α2 34.639 ms (349995 allocs: 48.217 MiB)
#1.11.rc 34.639 ms (349995 allocs: 48.217 MiB)
#
#testmat(9)^2 in GAP3 85ms in GAP4 60ms
"""
Expand All @@ -33,17 +33,17 @@ end;

#julia> @b collect(symmetric_group(10)) seconds=4
#1.10.3 240.491 ms (4043780 allocs: 336.001 MiB)
#1.11.α2 189.171 ms (8083258 allocs: 335.999 MiB)
#1.11.rc 189.171 ms (8083258 allocs: 335.999 MiB)
#Elements(Group(List([1..9],i->(i,i+1)),()));; GAP3 takes 0.56s

#julia> @b elements(coxgroup(:E,6))
#1.10.3 4.092 ms (60997 allocs: 12.434 MiB)
#1.11.α2 3.473 ms (118243 allocs: 13.182 MiB)
#1.11.rc 3.473 ms (118212 allocs: 13.208 MiB)
#Elements(CoxeterGroup("E",6));; #GAP3 15.5ms

#julia> @b test_kl(coxgroup(:A,4))
#1.10.3 5.870 ms (155260 allocs: 9.243 MiB)
#1.11.α2 5.558 ms (205790 allocs: 8.980 MiB)
#1.11.rc 5.558 ms (205766 allocs: 8.983 MiB)
function test_kl(W)
q=Pol([1],1)
H=hecke(W,q^2,rootpara=q)
Expand All @@ -61,7 +61,7 @@ end;

#julia> @b test_kl1(coxgroup(:A,4))
#1.10.2 24.752 ms (403416 allocs: 43.278 MiB)
#1.11.α2 22.338 ms (702082 allocs: 42.648 MiB)
#1.11.rc 22.338 ms (702087 allocs: 42.652 MiB)
function test_kl1(W)
q=Pol([1],1)
H=hecke(W,q^2,rootpara=q)
Expand All @@ -78,7 +78,7 @@ end;

#julia> @b test_kl2(coxgroup(:A,4))
#1.10.3 4.526 ms (87990 allocs: 7.199 MiB)
#1.11.α2 3.689 ms (164592 allocs: 6.844 MiB)
#1.11.rc 3.689 ms (164568 allocs: 6.847 MiB)
function test_kl2(W)
el=elements(W)
maximum(degree(KLPol(W,x,y)) for x in el, y in el)
Expand All @@ -100,7 +100,7 @@ end;
#1.8.5 248.055 μs (6433 allocations: 502.81 KiB)
#1.9.0 250.546 μs (6254 allocations: 517.97 KiB)
#1.10.3 264.118 μs (6200 allocs: 517.859 KiB)
#1.11.α2 230.321 μs (10200 allocs: 576.328 KiB)
#1.11.rc 230.321 μs (10200 allocs: 576.328 KiB)
function test_b(W)
B=BraidMonoid(W)
b=B(-4,-3,-2,-15,-14,-13,-10,-11,-12,-7,-2,-12,-11,-10,-7,-8,-9,-6,-7,-8,-2,
Expand All @@ -121,7 +121,7 @@ end;
# for r>13 needs BigInt
#julia> @b test_hm(BigInt,35) seconds=1
#1.10.3 42.886 ms (1795660 allocs: 57.618 MiB)
#1.11.α2 48.393 ms (1795664 allocs: 57.618 MiB)
#1.11.rc 48.393 ms (1795664 allocs: 57.618 MiB)
function test_hm(rtype,rank)
m=[rtype(1)//(n+m) for n in 1:rank, m in 1:rank]
one(m)==m*inv(m)
Expand All @@ -136,7 +136,7 @@ end;

#julia> @b PuiseuxPolynomials.fateman(7)
#1.10.3 15.031 ms (112807 allocs: 29.657 MiB)
#1.11.β1 14.864 ms (225638 allocs: 29.637 MiB)
#1.11.rc 14.864 ms (225638 allocs: 29.637 MiB)
# GAP3: fateman(7) takes 722ms
"""
fateman:=function(n)local p;
Expand All @@ -152,33 +152,32 @@ end;
#1.8 23.273 μs (621 allocations: 43.44 KiB)
#1.9.3 25.877 μs (662 allocations: 46.00 KiB)
#1.10.3 19.070 μs (429 allocs: 28.953 KiB)
#1.11.α2 15.460 μs (819 allocs: 29.016 KiB)
#1.11.rc 15.460 μs (819 allocs: 29.016 KiB)

# @b ((x,y)=Mvp.(:x,:y);inv(Frac.([x+y x-y;x+1 y+1])))
#1.6.3 187.233 μs (3941 allocations: 291.50 KiB)
#1.7.2 139.797 μs (3418 allocations: 236.66 KiB)
#1.8.5 137.125 μs (3102 allocations: 216.19 KiB)
#1.9.0 128.179 μs (2937 allocations: 210.86 KiB)
#1.10.3 153.370 μs (3631 allocs: 243.969 KiB)
#1.11.α2 122.602 μs (4994 allocs: 223.609 KiB)
# GAP3 invert Mvp matrix 3.9ms
# [[x+y,x-y],[x+1,y+1]]^-1;
#1.11.rc 122.602 μs (4994 allocs: 223.609 KiB)
# [[x+y,x-y],[x+1,y+1]]^-1; # GAP3 3.9ms

# @b CycPols.p(Pol()) #GAP3 1.25 ms
#1.8.5 254.158 μs (5626 allocations: 416.19 KiB)
#1.10.3 261.749 μs (5240 allocs: 394.188 KiB)
#1.11.α2 224.240 μs (7381 allocs: 379.156 KiB)
#1.11.rc 224.240 μs (7381 allocs: 379.156 KiB)

# @b CycPols.p(1) #GAP3 142μs
#1.8.5 5.140 μs (101 allocations: 19.88 KiB)
#1.10.3 6.162 μs (101.75 allocs: 21.152 KiB)
#1.11.α2 5.819 μs (151 allocs: 21.012 KiB)
#1.11.rc 5.819 μs (151 allocs: 21.012 KiB)
u=CycPols.p(Pol());
# @b u _(1) #GAP3 40μs
#1.8.5 24.669 μs (553 allocations: 41.91 KiB)
#1.10.3 27.458 μs (553 allocs: 41.906 KiB)
#1.11.α2 23.535 μs (828 allocs: 41.375 KiB)
#1.11.rc 23.535 μs (828 allocs: 41.375 KiB)
# @b u CycPol(_) #GAP3 8.2ms
#1.8.5 4.749 ms (92895 allocations: 7.35 MiB)
#1.10.3 4.906 ms (87044 allocs: 6.861 MiB)
#1.11.β1 3.931 ms (114898 allocs: 6.529 MiB)
#1.11.rc 3.931 ms (114917 allocs: 6.631 MiB)

0 comments on commit c769746

Please sign in to comment.