diff --git a/src/arithmetic.jl b/src/arithmetic.jl index a84e9c1..d5099c9 100644 --- a/src/arithmetic.jl +++ b/src/arithmetic.jl @@ -155,7 +155,7 @@ function addeq!(X::GroupRingElem{T}, a::T) where T return X end -function addeq!(X::GroupRingElem{T, GroupRing{R,G,El}}, g::El, v=1) where {T,R,G,El} +function addeq!(X::GroupRingElem{T, GroupRing{R,G,El}}, g::El, v=one(T)) where {T,R,G,El} @assert hasbasis(parent(X)) X[g] += T(v) return X @@ -177,14 +177,14 @@ end ### Scalar multiplication/scalar division -scalarmul!(a::T, X::GroupRingElem{T}) where T<:RingElement = (X.coeffs .*= a; return X) +scalarmul!(a::T, X::GroupRingElem{T}) where T = (X.coeffs .*= a; return X) function scalarmul(a::S, X::GroupRingElem{T}) where {S,T} if promote_type(S, T) == T return scalarmul!(base_ring(parent(X))(a), deepcopy(X)) else RG = change_base_ring(parent(X), parent(a)) - @warn "Coefficient ring does not contain scalar $a.\nThe result has coefficients in $(parent(a)) of type $(elem_type(parent(a)))." + @warn "Coefficient ring does not contain scalar $a;\nThe resulting GroupRingElem has coefficients in $(parent(a)) of type $(elem_type(parent(a)))." return scalarmul!(a, GroupRingElem(base_ring(RG).(X.coeffs), RG)) end end diff --git a/src/ncring_interface.jl b/src/ncring_interface.jl index b355aed..b9dc286 100644 --- a/src/ncring_interface.jl +++ b/src/ncring_interface.jl @@ -83,8 +83,8 @@ AbstractAlgebra.show_minus_one(::Type{<:GroupRingElem}) = true ############################################################################### function ==(X::GroupRingElem{T}, Y::GroupRingElem{S}) where {T,S} - if promote_type(T,S) ≠ T || promote_type(T,S) ≠ S - @warn "Comparing elements with incompatible coeffs Rings: $T and $S can be only compared as $(promote_type(T,S))" + if promote_type(T,S) ≠ T && promote_type(T,S) ≠ S + @warn "Comparing group ring elements over incompatible coefficient Rings:\n$T and $S can be only compared as $(promote_type(T,S))" end length(X.coeffs) == length(Y.coeffs) || return false parent(X).group == parent(Y).group || return false diff --git a/src/types.jl b/src/types.jl index 5225b3b..240f056 100644 --- a/src/types.jl +++ b/src/types.jl @@ -195,7 +195,7 @@ function complete!(RG::GroupRing, x = (twisted ? inv(RG[i]) : RG[i]) i_old = i end - RG.pm[i,j] = RG[AbstractAlgebra.mul!(res, x, RG[j])] + RG.pm[i,j] = RG[mul!(res, x, RG[j])] end end @@ -226,7 +226,7 @@ function create_pm(basis::AbstractVector{T}, basis_dict::Dict{T, <:Integer}, x = (twisted ? inv(basis[i]) : basis[i]) res = parent(x)() for j in 1:size(product_matrix, 2) - res = AbstractAlgebra.mul!(res, x, basis[j]) + res = mul!(res, x, basis[j]) product_matrix[i,j] = basis_dict[res] end end diff --git a/test/runtests.jl b/test/runtests.jl index 5c510a9..9588402 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,20 +4,23 @@ using AbstractAlgebra using GroupRings using SparseArrays +@testset "Group Rings tests" begin -include("unittests.jl") -include("usetests.jl") + include("unittests.jl") + include("usetests.jl") + let + include("AARing_interface_conformance.jl") + R = AbstractAlgebra.zz + G = PermGroup(4) -let - include("AARing_interface_conformance.jl") - R = AbstractAlgebra.zz - G = PermGroup(4) + RG = GroupRing(R, G, collect(G), halfradius_length=order(G)) - RG = GroupRing(R, G, collect(G), halfradius_length=order(G)) + X = rand(RG, 0.2, -3:3) + Y = rand(RG, 0.4, -1:1) - X = rand(RG, 0.2, -3:3) - Y = rand(RG, 0.4, -1:1) + # test_ringinterface(X, Y) + test_promote_rules(X, Y) + end - test_ringinterface(X, Y) end diff --git a/test/unittests.jl b/test/unittests.jl index ed32b2c..1496d73 100644 --- a/test/unittests.jl +++ b/test/unittests.jl @@ -1,6 +1,6 @@ using LinearAlgebra -@testset "unit tests" begin +@testset "Unit tests" begin R = AbstractAlgebra.zz G = PermGroup(4) diff --git a/test/usetests.jl b/test/usetests.jl index 23bcbbc..86abe1f 100644 --- a/test/usetests.jl +++ b/test/usetests.jl @@ -4,6 +4,7 @@ using AbstractAlgebra using GroupRings using SparseArrays +@testset "Use tests" begin @testset "Constructors: PermutationGroup" begin G = PermutationGroup(3) @@ -156,7 +157,7 @@ end @test eltype(2*a) == typeof(2) @test (2*a).coeffs == 2 .*(a.coeffs) - wt(c) = "Coefficient ring does not contain scalar $c.\nThe result has coefficients in $(parent(c)) of type $(elem_type(parent(c)))." + wt(c) = "Coefficient ring does not contain scalar $c;\nThe resulting GroupRingElem has coefficients in $(parent(c)) of type $(elem_type(parent(c)))." @test 2.0*a isa GroupRingElem @test_logs (:warn, wt(2.0)) eltype(2.0*a) == typeof(2.0) @@ -366,3 +367,5 @@ end (RG(2) - ∗(g*h) - k*l)^2 + 2(RG(2) - ∗(k) - l)^2 + 2(RG(2) - ∗(g) - h)^2 end + +end # of @testset "Use tests"