mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-11-11 12:35:27 +01:00
multiple dispatch of * and mul!
This commit is contained in:
parent
292806db17
commit
e61b573642
@ -291,7 +291,7 @@ end
|
|||||||
(+)(X::GroupRingElem, Y::GroupRingElem) = add(X,Y)
|
(+)(X::GroupRingElem, Y::GroupRingElem) = add(X,Y)
|
||||||
(-)(X::GroupRingElem, Y::GroupRingElem) = add(X,-Y)
|
(-)(X::GroupRingElem, Y::GroupRingElem) = add(X,-Y)
|
||||||
|
|
||||||
function groupring_mult!(X,Y,pm,result)
|
function mul!(X,Y,pm,result)
|
||||||
for (j,y) in enumerate(Y)
|
for (j,y) in enumerate(Y)
|
||||||
if y != zero(eltype(Y))
|
if y != zero(eltype(Y))
|
||||||
for (i, index) in enumerate(pm[:,j])
|
for (i, index) in enumerate(pm[:,j])
|
||||||
@ -304,17 +304,17 @@ function groupring_mult!(X,Y,pm,result)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function groupring_mult{T<:Number}(X::AbstractVector{T}, Y::AbstractVector{T},
|
function mul{T<:Number}(X::AbstractVector{T}, Y::AbstractVector{T},
|
||||||
pm::Array{Int,2})
|
pm::Array{Int,2})
|
||||||
result = zeros(X)
|
result = zeros(X)
|
||||||
groupring_mult!(X,Y,pm,result)
|
mul!(X,Y,pm,result)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function groupring_mult(X::AbstractVector, Y::AbstractVector, pm::Array{Int,2})
|
function mul(X::AbstractVector, Y::AbstractVector, pm::Array{Int,2})
|
||||||
T = promote_type(eltype(X), eltype(Y))
|
T = promote_type(eltype(X), eltype(Y))
|
||||||
result = zeros(T, deepcopy(X))
|
result = zeros(T, deepcopy(X))
|
||||||
groupring_mult!(X, Y, pm, result)
|
mul!(X, Y, pm, result)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ function *{T<:Number}(X::GroupRingElem{T}, Y::GroupRingElem{T})
|
|||||||
"Elements don't seem to belong to the same Group Ring!"))
|
"Elements don't seem to belong to the same Group Ring!"))
|
||||||
RG = parent(X)
|
RG = parent(X)
|
||||||
isdefined(RG, :pm) || complete(RG)
|
isdefined(RG, :pm) || complete(RG)
|
||||||
result = groupring_mult(X.coeffs, Y.coeffs, RG.pm)
|
result = mul(X.coeffs, Y.coeffs, RG.pm)
|
||||||
return GroupRingElem(result, RG)
|
return GroupRingElem(result, RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ function *{T<:Number, S<:Number}(X::GroupRingElem{T}, Y::GroupRingElem{S})
|
|||||||
warn("Multiplying elements with different base rings!")
|
warn("Multiplying elements with different base rings!")
|
||||||
RG = parent(X)
|
RG = parent(X)
|
||||||
isdefined(RG, :pm) || complete(RG)
|
isdefined(RG, :pm) || complete(RG)
|
||||||
result = groupring_mult(X.coeffs, Y.coeffs, RG.pm)
|
result = mul(X.coeffs, Y.coeffs, RG.pm)
|
||||||
return GroupRingElem(result, RG)
|
return GroupRingElem(result, RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user