1
0
mirror of https://github.com/kalmarek/GroupRings.jl.git synced 2024-12-29 11:00:28 +01:00

use Base.one instead of (::Group)()

This commit is contained in:
kalmarek 2019-11-19 11:30:29 +01:00
parent ce6ef70d55
commit 9225d2153f
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 10 additions and 10 deletions

View File

@ -53,7 +53,7 @@ mutable struct GroupRingElem{T, A<:AbstractVector, GR<:GroupRing} <: NCRingElem
"Can't create GroupRingElem -- lengths differ: length(c) = "Can't create GroupRingElem -- lengths differ: length(c) =
$(length(c)) != $(length(RG.basis)) = length(RG.basis)") $(length(c)) != $(length(RG.basis)) = length(RG.basis)")
else else
@warn("Basis of the GroupRing is not defined.") # @warn("Basis of the GroupRing is not defined.")
end end
end end
return new{T, A, GR}(c, RG) return new{T, A, GR}(c, RG)
@ -114,7 +114,7 @@ end
# sparse storage: # sparse storage:
zero(RG::GroupRing, T::Type=Int) = RG(T) zero(RG::GroupRing, T::Type=Int) = RG(T)
one(RG::GroupRing, T::Type=Int) = RG(RG.group(), T) one(RG::GroupRing, T::Type=Int) = RG(one(RG.group), T)
one(RG::GroupRing{<:AbstractAlgebra.NCRing}, T::Type=Int) = RG(one(RG.group), T) one(RG::GroupRing{<:AbstractAlgebra.NCRing}, T::Type=Int) = RG(one(RG.group), T)
function (RG::GroupRing)(T::Type=Int) function (RG::GroupRing)(T::Type=Int)
@ -124,7 +124,7 @@ end
function (RG::GroupRing)(i::Int, T::Type=Int) function (RG::GroupRing)(i::Int, T::Type=Int)
elt = RG(T) elt = RG(T)
elt[RG.group()] = i elt[one(RG.group)] = i
return elt return elt
end end
@ -229,7 +229,7 @@ function show(io::IO, X::GroupRingElem)
RG = parent(X) RG = parent(X)
T = eltype(X.coeffs) T = eltype(X.coeffs)
if X.coeffs == zero(X.coeffs) if X.coeffs == zero(X.coeffs)
print(io, "$(zero(T))*$((RG.group)())") print(io, "$(zero(T))*$(one(RG.group))")
elseif isdefined(RG, :basis) elseif isdefined(RG, :basis)
non_zeros = ((X.coeffs[i], RG.basis[i]) for i in findall(!iszero, X.coeffs)) non_zeros = ((X.coeffs[i], RG.basis[i]) for i in findall(!iszero, X.coeffs))
elts = String[] elts = String[]

View File

@ -49,7 +49,7 @@ using SparseArrays
S = gens(F) S = gens(F)
append!(S, [inv(s) for s in S]) append!(S, [inv(s) for s in S])
basis, sizes = Groups.generate_balls(S, F(), radius=4) basis, sizes = Groups.generate_balls(S, one(F), radius=4)
d = GroupRings.reverse_dict(basis) d = GroupRings.reverse_dict(basis)
@test_throws KeyError create_pm(basis) @test_throws KeyError create_pm(basis)
pm = create_pm(basis, d, sizes[2]) pm = create_pm(basis, d, sizes[2])
@ -67,7 +67,7 @@ using SparseArrays
GroupRings.complete!(RF) GroupRings.complete!(RF)
@test count(!iszero, RF.pm) == 45469 @test count(!iszero, RF.pm) == 45469
g = B() g = zero(B)
s = S[2] s = S[2]
g[s] = 1 g[s] = 1
@test g == B(s) @test g == B(s)
@ -217,7 +217,7 @@ using SparseArrays
@test aug(z) == 0 @test aug(z) == 0
@test supp(z) == parent(z).basis @test supp(z) == parent(z).basis
@test supp(RG(1) + RG(perm"(2,3)")) == [G(), perm"(2,3)"] @test supp(RG(1) + RG(perm"(2,3)")) == [one(G), perm"(2,3)"]
@test supp(a) == [perm"(3)", perm"(2,3)", perm"(1,2,3)"] @test supp(a) == [perm"(3)", perm"(2,3)", perm"(1,2,3)"]
end end
@ -228,8 +228,8 @@ using SparseArrays
RG = GroupRing(G, cachedmul=true) RG = GroupRing(G, cachedmul=true)
RG2 = GroupRing(G, cachedmul=false) RG2 = GroupRing(G, cachedmul=false)
Z = RG() Z = zero(RG)
W = RG() W = zero(RG)
for g in [rand(G) for _ in 1:30] for g in [rand(G) for _ in 1:30]
X = RG(g) X = RG(g)
@ -258,7 +258,7 @@ using SparseArrays
S = G.(G.gens) S = G.(G.gens)
S = [S; inv.(S)] S = [S; inv.(S)]
ID = G() ID = one(G)
RADIUS=3 RADIUS=3
@time E_R, sizes = Groups.generate_balls(S, ID, radius=2*RADIUS); @time E_R, sizes = Groups.generate_balls(S, ID, radius=2*RADIUS);
@test sizes == [9, 65, 457, 3201, 22409, 156865] @test sizes == [9, 65, 457, 3201, 22409, 156865]