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

remove warnings

This commit is contained in:
kalmarek 2020-10-04 21:12:18 +02:00
parent 8178af6530
commit 3054fa40d1
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 15 additions and 42 deletions

View File

@ -257,9 +257,6 @@ end
############################################################################### ###############################################################################
function (==)(X::GroupRingElem, Y::GroupRingElem) function (==)(X::GroupRingElem, Y::GroupRingElem)
if eltype(X.coeffs) != eltype(Y.coeffs)
@warn("Comparing elements with different coeffs Rings!")
end
suppX = supp(X) suppX = supp(X)
suppX == supp(Y) || return false suppX == supp(Y) || return false
@ -282,6 +279,9 @@ end
hasbasis(A::GroupRing) = isdefined(A, :basis) hasbasis(A::GroupRing) = isdefined(A, :basis)
Base.deepcopy_internal(x::GroupRingElem, dict::IdDict) =
parent(x)(deepcopy(x.coeffs))
############################################################################### ###############################################################################
# #
# Scalar operators # Scalar operators
@ -295,11 +295,13 @@ function mul!(a::T, X::GroupRingElem{T}) where T
return X return X
end end
Base.:*(a::Number, X::GroupRingElem) = GroupRingElem(a*X.coeffs, parent(X)) _mul(a::Number, X::GroupRingElem) = GroupRingElem(a*X.coeffs, parent(X))
Base.:*(a::Number, X::GroupRingElem) = _mul(a, X)
Base.:*(X::GroupRingElem, a::Number) = a*X Base.:*(X::GroupRingElem, a::Number) = a*X
# disallow Rings to hijack *(::, ::GroupRingElem) # disallow Rings to hijack *(::, ::GroupRingElem)
*(a::Union{AbstractFloat, Integer, RingElem, Rational}, X::GroupRingElem) = mul(a, X) *(a::Union{AbstractFloat, Integer, RingElem, Rational}, X::GroupRingElem) = _mul(a, X)
(/)(X::GroupRingElem, a) = 1/a*X (/)(X::GroupRingElem, a) = 1/a*X
(//)(X::GroupRingElem, a::Union{Integer, Rational}) = 1//a*X (//)(X::GroupRingElem, a::Union{Integer, Rational}) = 1//a*X
@ -317,21 +319,8 @@ function addeq!(X::GroupRingElem, Y::GroupRingElem)
return X return X
end end
function +(X::GroupRingElem{T}, Y::GroupRingElem{T}) where T Base.:+(X::GroupRingElem, Y::GroupRingElem) = addeq!(deepcopy(X), Y)
return GroupRingElem(X.coeffs+Y.coeffs, parent(X)) -(X::GroupRingElem, Y::GroupRingElem) where T = addeq!((-Y), X)
end
function +(X::GroupRingElem{S}, Y::GroupRingElem{T}) where {S, T}
@warn("Adding elements with different coefficient rings, Promoting result to $(promote_type(T,S))")
return GroupRingElem(X.coeffs+Y.coeffs, parent(X))
end
-(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
""" """
fmac!(result::AbstractVector{T}, fmac!(result::AbstractVector{T},
@ -445,34 +434,18 @@ function mul!(result::GroupRingElem, X::GroupRingElem, Y::GroupRingElem)
return result return result
end end
function *(X::GroupRingElem{T}, Y::GroupRingElem{T}, check::Bool=true) where T
if check
parent(X) === parent(Y) || throw("Elements don't seem to belong to the same Group Ring!")
end
if hasbasis(parent(X))
result = parent(X)(similar(X.coeffs))
result = mul!(result, X, Y)
else
result = GRmul!(similar(X.coeffs), X.coeffs, Y.coeffs, parent(X).pm)
result = GroupRingElem(result, parent(X))
end
return result
end
function *(X::GroupRingElem{T}, Y::GroupRingElem{S}, check::Bool=true) where {T,S} function *(X::GroupRingElem{T}, Y::GroupRingElem{S}, check::Bool=true) where {T,S}
if check if check
parent(X) === parent(Y) || throw("Elements don't seem to belong to the same Group Ring!") parent(X) === parent(Y) || throw("Elements don't seem to belong to the same Group Ring!")
end end
TT = typeof(first(X.coeffs)*first(Y.coeffs)) TT = promote_type(T,S)
@warn("Multiplying elements with different base rings! Promoting the result to $TT.")
if hasbasis(parent(X)) if hasbasis(parent(X))
result = parent(X)(similar(X.coeffs)) result = parent(X)(similar(X.coeffs, TT))
result = convert(TT, result)
result = mul!(result, X, Y) result = mul!(result, X, Y)
else else
result = convert(TT, similar(X.coeffs)) result = similar(X.coeffs, TT)
result = RGmul!(result, X.coeffs, Y.coeffs, parent(X).pm) result = RGmul!(result, X.coeffs, Y.coeffs, parent(X).pm)
result = GroupRingElem(result, parent(X)) result = GroupRingElem(result, parent(X))
end end

View File

@ -145,10 +145,10 @@ using SparseArrays
ww = "Scalar and coeffs are in different rings! Promoting result to Float64" ww = "Scalar and coeffs are in different rings! Promoting result to Float64"
@test isa(2.0*a, GroupRingElem) @test isa(2.0*a, GroupRingElem)
@test_logs (:warn, ww) eltype(2.0*a) == typeof(2.0) @test eltype(2.0*a) == typeof(2.0)
@test_logs (:warn, ww) (2.0*a).coeffs == 2.0.*(a.coeffs) @test (2.0*a).coeffs == 2.0.*(a.coeffs)
@test_logs (:warn, ww) (a/2).coeffs == a.coeffs./2 @test (a/2).coeffs == a.coeffs./2
b = a/2 b = a/2
@test isa(b, GroupRingElem) @test isa(b, GroupRingElem)
@test eltype(b) == typeof(1/2) @test eltype(b) == typeof(1/2)