more small fixes

This commit is contained in:
kalmarek 2019-06-06 17:52:58 +02:00
parent 65d2df3a40
commit d1b8d90c56
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
6 changed files with 25 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
using LinearAlgebra
@testset "unit tests" begin
@testset "Unit tests" begin
R = AbstractAlgebra.zz
G = PermGroup(4)

View File

@ -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"