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

Merge remote-tracking branch 'origin/AutFn' into enh/julia-v0.7

This commit is contained in:
kalmarek 2019-01-02 16:21:58 +01:00
commit ecc44a8da6
2 changed files with 128 additions and 17 deletions

View File

@ -340,8 +340,43 @@ function -(X::GroupRingElem{S}, Y::GroupRingElem{T}) where {S, T}
addeq!((-Y), X)
end
@doc doc"""
mul!(result::AbstractArray{T},
doc"""
fmac!(result::AbstractVector{T},
X::AbstractVector,
Y::AbstractVector,
pm::Array{Int,2}) where {T<:Number}
> Fused multiply-add for group ring coeffs using multiplication table `pm`.
> The result of X*Y in GroupRing is added in-place to `result`.
> Notes:
> * this method will silently produce false results if `X[k]` is non-zero for
> `k > size(pm,1)`.
> * This method will fail if any zeros (i.e. uninitialised entries) are present
> in `pm`.
> Use with extreme care!
"""
function fmac!(result::AbstractVector{T},
X::AbstractVector,
Y::AbstractVector,
pm::Array{Int,2}) where {T<:Number}
z = zero(T)
s1 = size(pm,1)
s2 = size(pm,2)
@inbounds for j in 1:s2
if Y[j] != z
for i in 1:s1
if X[i] != z
result[pm[i,j]] += X[i]*Y[j]
end
end
end
end
return result
end
doc"""
mul!(result::AbstractVector{T},
X::AbstractVector,
Y::AbstractVector,
pm::Array{Int,2}) where {T<:Number}
@ -360,24 +395,12 @@ function mul!(result::AbstractVector{T},
pm::Array{Int,2}) where {T<:Number}
z = zero(T)
result .= z
lY = length(Y)
s = size(pm,1)
@inbounds for j in 1:lY
if Y[j] != z
for i in 1:s
if X[i] != z
pm[i,j] == 0 && throw(ArgumentError("The product don't seem to be supported on basis!"))
result[pm[i,j]] += X[i]*Y[j]
end
end
end
end
return result
return fmac!(result, X, Y, pm)
end
@doc doc"""
mul!(result::GroupRingElem{T},
doc"""
mul!{T}(result::GroupRingElem{T},
X::GroupRingElem,
Y::GroupRingElem)
> In-place multiplication for `GroupRingElem`s `X` and `Y`.

View File

@ -211,4 +211,92 @@ using SparseArrays
end
end
@testset "SumOfSquares in group rings" begin
= star
G = FreeGroup(["g", "h", "k", "l"])
S = G.(G.gens)
S = [S; inv.(S)]
ID = G()
RADIUS=3
@time E_R, sizes = Groups.generate_balls(S, ID, radius=2*RADIUS);
@test sizes == [9, 65, 457, 3201, 22409, 156865]
E_rdict = GroupRings.reverse_dict(E_R)
pm = GroupRings.create_pm(E_R, E_rdict, sizes[RADIUS]; twisted=true);
RG = GroupRing(G, E_R, E_rdict, pm)
g = RG.basis[2]
h = RG.basis[3]
k = RG.basis[4]
l = RG.basis[5]
G = (1-RG(g))
@test G^2 == 2 - RG(g) - (RG(g))
G = (1-RG(g))
H = (1-RG(h))
K = (1-RG(k))
L = (1-RG(l))
GH = (1-RG(g*h))
KL = (1-RG(k*l))
X = (2 - (RG(g)) - RG(h))
Y = (2 - (RG(g*h)) - RG(k))
@test -(2 - RG(g*h) - (RG(g*h))) + 2G^2 + 2H^2 == X^2
@test (2 - RG(g*h) - (RG(g*h))) == GH^2
@test -(2 - RG(g*h*k) - (RG(g*h*k))) + 2GH^2 + 2K^2 == Y^2
@test -(2 - RG(g*h*k) - (RG(g*h*k))) +
2(GH^2 - 2G^2 - 2H^2) +
4G^2 + 4H^2 + 2K^2 ==
Y^2
@test GH^2 - 2G^2 - 2H^2 == - X^2
@test -(2 - RG(g*h*k) - (RG(g*h*k))) + 4G^2 + 4H^2 + 2K^2 == 2X^2 + Y^2
@test GH^2 == 2G^2 + 2H^2 - (2 - (RG(g)) - RG(h))^2
@test KL^2 == 2K^2 + 2L^2 - (2 - (RG(k)) - RG(l))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) + 2*GH^2 + 2*KL^2 ==
(2 - (RG(g*h)) - RG(k*l))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) +
2(2G^2 + 2H^2 - (2 - (RG(g)) - RG(h))^2) +
2(2K^2 + 2L^2 - (2 - (RG(k)) - RG(l))^2) ==
(2 - (RG(g*h)) - RG(k*l))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) +
2(2G^2 + 2H^2) +
2(2K^2 + 2L^2) ==
(2 - (RG(g*h)) - RG(k*l))^2 +
2(2 - (RG(g)) - RG(h))^2 +
2(2 - (RG(k)) - RG(l))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) +
2(2 - (RG(g*h*k)) - RG(g*h*k)) + 2L^2 ==
(2 - (RG(g*h*k)) - RG(l))^2
@test 2 - (RG(g*h*k)) - RG(g*h*k) ==
2GH^2 + 2K^2 - (2 - (RG(g*h)) - RG(k))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) +
2(2GH^2 + 2K^2 - (2 - (RG(g*h)) - RG(k))^2) + 2L^2 ==
(2 - (RG(g*h*k)) - RG(l))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) +
2(2GH^2 + 2K^2) + 2L^2 ==
(2 - (RG(g*h*k)) - RG(l))^2 +
2(2 - (RG(g*h)) - RG(k))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) +
8G^2 + 8H^2 + 4K^2 + 2L^2 ==
(2 - (RG(g*h*k)) - RG(l))^2 + 2(2 - (RG(g*h)) - RG(k))^2 + 4(2 - (RG(g)) - RG(h))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) +
2GH^2 + 2KL^2 == (2 - (RG(g*h)) - RG(k*l))^2
@test -(2 - (RG(g*h*k*l)) - RG(g*h*k*l)) + 2(2G^2 + 2H^2) + 2(2K^2 + 2L^2) ==
(2 - (RG(g*h)) - RG(k*l))^2 + 2(2 - (RG(k)) - RG(l))^2 + 2(2 - (RG(g)) - RG(h))^2
end
end