mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-11-19 14:35:27 +01:00
fix addition/subtraction for different coeff types
This commit is contained in:
parent
6b2cd781c7
commit
2fee695b51
@ -301,7 +301,7 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function addeq!(X::GroupRingElem{T}, Y::GroupRingElem{T}) where T
|
function addeq!(X::GroupRingElem, Y::GroupRingElem)
|
||||||
X.coeffs += Y.coeffs
|
X.coeffs += Y.coeffs
|
||||||
return X
|
return X
|
||||||
end
|
end
|
||||||
@ -310,12 +310,17 @@ function +(X::GroupRingElem{T}, Y::GroupRingElem{T}) where T
|
|||||||
return GroupRingElem(X.coeffs+Y.coeffs, parent(X))
|
return GroupRingElem(X.coeffs+Y.coeffs, parent(X))
|
||||||
end
|
end
|
||||||
|
|
||||||
function +(X::GroupRingElem{T}, Y::GroupRingElem{S}) where {T,S}
|
function +(X::GroupRingElem{S}, Y::GroupRingElem{T}) where {S, T}
|
||||||
warn("Adding elements with different coefficient rings, Promoting result to $(promote_type(T,S))")
|
warn("Adding elements with different coefficient rings, Promoting result to $(promote_type(T,S))")
|
||||||
return GroupRingElem(X.coeffs+Y.coeffs, parent(X))
|
return GroupRingElem(X.coeffs+Y.coeffs, parent(X))
|
||||||
end
|
end
|
||||||
|
|
||||||
(-)(X::GroupRingElem, Y::GroupRingElem) = addeq!((-Y), X)
|
-(X::GroupRingElem{T}, Y::GroupRingElem{T}) where T = addeq!((-Y), X)
|
||||||
|
|
||||||
|
function -(X::GroupRingElem{S}, Y::GroupRingElem{T}) where {S, T}
|
||||||
|
warn("Adding elements with different coefficient rings, Promoting result to $(promote_type(T,S))")
|
||||||
|
addeq!((-Y), X)
|
||||||
|
end
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
mul!(result::AbstractArray{T},
|
mul!(result::AbstractArray{T},
|
||||||
|
@ -165,6 +165,15 @@ using GroupRings
|
|||||||
a = RG(ones(Int, order(G)))
|
a = RG(ones(Int, order(G)))
|
||||||
b = sum((-1)^parity(g)*RG(g) for g in elements(G))
|
b = sum((-1)^parity(g)*RG(g) for g in elements(G))
|
||||||
@test 1/2*(a+b).coeffs == [1.0, 0.0, 1.0, 0.0, 1.0, 0.0]
|
@test 1/2*(a+b).coeffs == [1.0, 0.0, 1.0, 0.0, 1.0, 0.0]
|
||||||
|
|
||||||
|
a = RG(1) + RG(perm"(2,3)") + RG(perm"(1,2,3)")
|
||||||
|
b = RG(1) - RG(perm"(1,2)(3)") - RG(perm"(1,2,3)")
|
||||||
|
|
||||||
|
@test a - b == RG(perm"(2,3)") + RG(perm"(1,2)(3)") + 2RG(perm"(1,2,3)")
|
||||||
|
|
||||||
|
@test 1//2*2a == a
|
||||||
|
@test a + 2a == (3//1)*a
|
||||||
|
@test 2a - (1//1)*a == a
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Multiplicative structure" begin
|
@testset "Multiplicative structure" begin
|
||||||
|
Loading…
Reference in New Issue
Block a user