Skip to content

Commit

Permalink
Add symmetrize, bump julia compat (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Oct 17, 2024
1 parent d1754fa commit 2060968
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 8 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/OscarTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ jobs:
fail-fast: false
matrix:
julia-version:
- '1.6'
- '1.8'
- '1.10'
- '1.11-nightly'
- '1.11'
# - '1.12-nightly'
- 'nightly'
julia-arch:
- x64
os:
- ubuntu-latest
# include:
# Add a few macOS jobs (not too many, the number we can run in parallel is limited)
# - julia-version: '1.6'
# - julia-version: '1.8'
# julia-arch: x64
# os: macOS-latest
# - julia-version: 'nightly'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ jobs:
fail-fast: false
matrix:
julia-version:
- '1.6'
- '1.8'
- '1.10'
- '1.11-nightly'
- '1.11'
# - '1.12-nightly'
- 'nightly'
julia-arch:
- x64
os:
- ubuntu-latest
# include:
# Add a few macOS jobs (not too many, the number we can run in parallel is limited)
# - julia-version: '1.6'
# - julia-version: '1.8'
# julia-arch: x64
# os: macOS-latest
# - julia-version: 'nightly'
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Oscar = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13"

[compat]
Oscar = "~1.0.3, ~1.1"
julia = "1.6"
julia = "1.8"
2 changes: 1 addition & 1 deletion src/DeformationBases/ArcDiagDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ function arcdiag_to_deformationmap_entry(
fill(C(1 // factorial(length(basiselem))), factorial(length(basiselem))),
[ind for ind in permutations(basiselem)],
),
)
) # TODO: benchmark use of `symmetrize` here once it is implemented with mutable arithmetics
entry_summand += coeff_lower_labels * symm_basiselem
end
# end inner
Expand Down
12 changes: 12 additions & 0 deletions src/Misc.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function symmetrize(f::FreeAssAlgElem)
R = parent(f)
g = zero(R)
for (c, exp) in zip(AbstractAlgebra.coefficients(f), AbstractAlgebra.exponent_words(f))
g += R(
fill(c * QQ(1, factorial(length(exp))), factorial(length(exp))),
[ind for ind in permutations(exp)],
)

end
return g
end
16 changes: 16 additions & 0 deletions src/OscarPatches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ if !isdefined(Oscar, :free_associative_algebra_type)
free_associative_algebra_type(x) = free_associative_algebra_type(typeof(x)) # to stop this method from eternally recursing on itself, we better add ...
free_associative_algebra_type(::Type{T}) where T = throw(ArgumentError("Type `$T` must be subtype of `RingElement`."))
end

#=
if !hasmethod(Oscar._is_homogeneous, Tuple{FreeAssAlgElem})
function Oscar._is_homogeneous(f::FreeAssAlgElem)
length(f) <= 1 && return true
leadexpv, tailexpvs = Iterators.peel(AbstractAlgebra.exponent_words(f))
d = length(leadexpv)
for tailexpv in tailexpvs
if d!=length(tailexpv)
return false
end
end
return true
end
end
=#
2 changes: 2 additions & 0 deletions src/PBWDeformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export standard_module
export symmetric_deformation
export symmetric_power
export symmetric_power_obj
export symmetrize
export tensor_power
export tensor_power_obj
export to_arcdiag
Expand All @@ -128,6 +129,7 @@ include("Types.jl")

include("LinearIndependence.jl")
include("ModuleSimpleStructure.jl")
include("Misc.jl")

include("DeformationBases/DeformBasis.jl")

Expand Down
4 changes: 4 additions & 0 deletions src/SmashProductLie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ function comm(e1::SmashProductLieElem, e2::SmashProductLieElem)
return parent(e1)(data(e1) * data(e2) - data(e2) * data(e1))
end

function symmetrize(e::SmashProductLieElem)
return parent(e)(symmetrize(data(e)))
end

###############################################################################
#
# Comparison functions
Expand Down
4 changes: 4 additions & 0 deletions src/SmashProductLieDeform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ function comm(e1::SmashProductLieDeformElem, e2::SmashProductLieDeformElem)
return parent(e1)(data(e1) * data(e2) - data(e2) * data(e1))
end

function symmetrize(e::SmashProductLieDeformElem)
return parent(e)(symmetrize(data(e)))
end

###############################################################################
#
# Comparison functions
Expand Down
49 changes: 49 additions & 0 deletions test/Misc-test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@testset "Misc.jl tests" begin
@testset "symmetrize" begin
R, (x,y,z, t) = free_associative_algebra(QQ, [:x,:y,:z, :t])

@test symmetrize(x) == x

@test symmetrize(x*y) == QQ(1//2) * (x*y + y*x)
@test symmetrize(y^2) == y^2

@test symmetrize(x*y*z) == QQ(1//6) * (x*y*z + x*z*y + y*x*z + y*z*x + z*x*y + z*y*x)
@test allequal([symmetrize(x*y*z), symmetrize(x*z*y), symmetrize(y*x*z), symmetrize(y*z*x), symmetrize(z*x*y), symmetrize(z*y*x)])
@test symmetrize(x^2*y) == QQ(2//6) * (x^2*y + x*y*x + y*x^2)
@test allequal([symmetrize(x^2*y), symmetrize(x*y*x), symmetrize(y*x^2)])
@test symmetrize(z^3) == z^3

@test symmetrize(x*y*z*t) == QQ(1//24) * (
x*y*z*t + x*y*t*z + x*z*y*t + x*z*t*y + x*t*y*z + x*t*z*y +
y*x*z*t + y*x*t*z + y*z*x*t + y*z*t*x + y*t*x*z + y*t*z*x +
z*x*y*t + z*x*t*y + z*y*x*t + z*y*t*x + z*t*x*y + z*t*y*x +
t*x*y*z + t*x*z*y + t*y*x*z + t*y*z*x + t*z*x*y + t*z*y*x
)
@test symmetrize(x^2*y*z) == QQ(2//24) * (
x^2*y*z + x^2*z*y + x*y*x*z + x*y*z*x + x*z*x*y + x*z*y*x + y*x^2*z + y*x*z*x + y*z*x^2 + z*x^2*y + z*x*y*x + z*y*x^2
)
@test allequal([
symmetrize(x^2 * y * z),
symmetrize(x^2 * z * y),
symmetrize(x * y * x * z),
symmetrize(x * y * z * x),
symmetrize(x * z * x * y),
symmetrize(x * z * y * x),
symmetrize(y * x^2 * z),
symmetrize(y * x * z * x),
symmetrize(y * z * x^2),
symmetrize(z * x^2 * y),
symmetrize(z * x * y * x),
symmetrize(z * y * x^2),
])
@test symmetrize(x^3*y) == QQ(6//24) * (x^3*y + x^2*y*x + x*y*x^2 + y*x^3)
@test allequal([symmetrize(x^3*y), symmetrize(x^2*y*x), symmetrize(x*y*x^2), symmetrize(y*x^3)])
@test symmetrize(x^2*y^2) == QQ(2*2//24) * (x*x*y*y + x*y*x*y + x*y*y*x + y*x*x*y + y*x*y*x + y*y*x*x)
@test allequal([symmetrize(x*x*y*y), symmetrize(x*y*x*y), symmetrize(x*y*y*x), symmetrize(y*x*x*y), symmetrize(y*x*y*x), symmetrize(y*y*x*x)])
@test symmetrize(t^4) == t^4

# test linearity
@test symmetrize(2*y^4*z*x - z*x*z^2*y*x + 9*x^2*z*x^2 + QQ(5//3)*y*z*x^2*z - 4*x*y^2 + z*x^2 + QQ(9//5)*z*x) ==
2*symmetrize(y^4*z*x) - symmetrize(z*x*z^2*y*x) + 9*symmetrize(x^2*z*x^2) + QQ(5//3)*symmetrize(y*z*x^2*z) - 4*symmetrize(x*y^2) + symmetrize(z*x^2) + QQ(9//5)*symmetrize(z*x)
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Oscar.with_unicode(true) do
include("ArcDiagram-test.jl")
include("DeformationBases-test.jl")
include("LinearIndependence-test.jl")
include("Misc-test.jl")
include("Pseudograph-test.jl")
include("SmashProductLie-test.jl")
include("SmashProductLieDeform-test.jl")
Expand Down

0 comments on commit 2060968

Please sign in to comment.