mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2025-01-01 11:45:28 +01:00
more small fixes
This commit is contained in:
parent
65d2df3a40
commit
d1b8d90c56
@ -155,7 +155,7 @@ function addeq!(X::GroupRingElem{T}, a::T) where T
|
|||||||
return X
|
return X
|
||||||
end
|
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))
|
@assert hasbasis(parent(X))
|
||||||
X[g] += T(v)
|
X[g] += T(v)
|
||||||
return X
|
return X
|
||||||
@ -177,14 +177,14 @@ end
|
|||||||
|
|
||||||
### Scalar multiplication/scalar division
|
### 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}
|
function scalarmul(a::S, X::GroupRingElem{T}) where {S,T}
|
||||||
if promote_type(S, T) == T
|
if promote_type(S, T) == T
|
||||||
return scalarmul!(base_ring(parent(X))(a), deepcopy(X))
|
return scalarmul!(base_ring(parent(X))(a), deepcopy(X))
|
||||||
else
|
else
|
||||||
RG = change_base_ring(parent(X), parent(a))
|
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))
|
return scalarmul!(a, GroupRingElem(base_ring(RG).(X.coeffs), RG))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -83,8 +83,8 @@ AbstractAlgebra.show_minus_one(::Type{<:GroupRingElem}) = true
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function ==(X::GroupRingElem{T}, Y::GroupRingElem{S}) where {T,S}
|
function ==(X::GroupRingElem{T}, Y::GroupRingElem{S}) where {T,S}
|
||||||
if promote_type(T,S) ≠ T || promote_type(T,S) ≠ 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))"
|
@warn "Comparing group ring elements over incompatible coefficient Rings:\n$T and $S can be only compared as $(promote_type(T,S))"
|
||||||
end
|
end
|
||||||
length(X.coeffs) == length(Y.coeffs) || return false
|
length(X.coeffs) == length(Y.coeffs) || return false
|
||||||
parent(X).group == parent(Y).group || return false
|
parent(X).group == parent(Y).group || return false
|
||||||
|
@ -195,7 +195,7 @@ function complete!(RG::GroupRing,
|
|||||||
x = (twisted ? inv(RG[i]) : RG[i])
|
x = (twisted ? inv(RG[i]) : RG[i])
|
||||||
i_old = i
|
i_old = i
|
||||||
end
|
end
|
||||||
RG.pm[i,j] = RG[AbstractAlgebra.mul!(res, x, RG[j])]
|
RG.pm[i,j] = RG[mul!(res, x, RG[j])]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ function create_pm(basis::AbstractVector{T}, basis_dict::Dict{T, <:Integer},
|
|||||||
x = (twisted ? inv(basis[i]) : basis[i])
|
x = (twisted ? inv(basis[i]) : basis[i])
|
||||||
res = parent(x)()
|
res = parent(x)()
|
||||||
for j in 1:size(product_matrix, 2)
|
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]
|
product_matrix[i,j] = basis_dict[res]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,20 +4,23 @@ using AbstractAlgebra
|
|||||||
using GroupRings
|
using GroupRings
|
||||||
using SparseArrays
|
using SparseArrays
|
||||||
|
|
||||||
|
@testset "Group Rings tests" begin
|
||||||
|
|
||||||
include("unittests.jl")
|
include("unittests.jl")
|
||||||
include("usetests.jl")
|
include("usetests.jl")
|
||||||
|
|
||||||
|
let
|
||||||
|
include("AARing_interface_conformance.jl")
|
||||||
|
R = AbstractAlgebra.zz
|
||||||
|
G = PermGroup(4)
|
||||||
|
|
||||||
let
|
RG = GroupRing(R, G, collect(G), halfradius_length=order(G))
|
||||||
include("AARing_interface_conformance.jl")
|
|
||||||
R = AbstractAlgebra.zz
|
|
||||||
G = PermGroup(4)
|
|
||||||
|
|
||||||
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)
|
# test_ringinterface(X, Y)
|
||||||
Y = rand(RG, 0.4, -1:1)
|
test_promote_rules(X, Y)
|
||||||
|
end
|
||||||
|
|
||||||
test_ringinterface(X, Y)
|
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using LinearAlgebra
|
using LinearAlgebra
|
||||||
|
|
||||||
@testset "unit tests" begin
|
@testset "Unit tests" begin
|
||||||
R = AbstractAlgebra.zz
|
R = AbstractAlgebra.zz
|
||||||
G = PermGroup(4)
|
G = PermGroup(4)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ using AbstractAlgebra
|
|||||||
using GroupRings
|
using GroupRings
|
||||||
using SparseArrays
|
using SparseArrays
|
||||||
|
|
||||||
|
@testset "Use tests" begin
|
||||||
|
|
||||||
@testset "Constructors: PermutationGroup" begin
|
@testset "Constructors: PermutationGroup" begin
|
||||||
G = PermutationGroup(3)
|
G = PermutationGroup(3)
|
||||||
@ -156,7 +157,7 @@ end
|
|||||||
@test eltype(2*a) == typeof(2)
|
@test eltype(2*a) == typeof(2)
|
||||||
@test (2*a).coeffs == 2 .*(a.coeffs)
|
@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 2.0*a isa GroupRingElem
|
||||||
@test_logs (:warn, wt(2.0)) eltype(2.0*a) == typeof(2.0)
|
@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 +
|
(RG(2) - ∗(g*h) - k*l)^2 +
|
||||||
2(RG(2) - ∗(k) - l)^2 + 2(RG(2) - ∗(g) - h)^2
|
2(RG(2) - ∗(k) - l)^2 + 2(RG(2) - ∗(g) - h)^2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end # of @testset "Use tests"
|
||||||
|
Loading…
Reference in New Issue
Block a user