1
0
mirror of https://github.com/kalmarek/GroupRings.jl.git synced 2024-07-16 10:40:29 +02:00

allocation-free multiplication!

# Conflicts:
#	src/GroupRings.jl
This commit is contained in:
kalmar 2017-07-12 20:53:17 +02:00
parent 90106359e4
commit 6ac5800379

View File

@ -301,14 +301,15 @@ 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 mul!{T<:Number}(X::AbstractVector{T}, Y::AbstractVector{T}, function mul!{T}(result::AbstractVector{T}, X::AbstractVector, Y::AbstractVector, pm::Array{Int,2})
pm::Array{Int,2}, result::AbstractVector{T}) z = zero(T)
for (j,y) in enumerate(Y) result .= z
if y != zero(eltype(Y)) for j in eachindex(Y)
for (i, index) in enumerate(pm[:,j]) if Y[j] != z
if X[i] != zero(eltype(X)) for i in 1:size(pm,1)
index == 0 && throw(ArgumentError("The product don't seem to belong to the span of basis!")) if X[i] != z
result[index] += X[i]*y 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
end end