From 48645a7b5cc0c8bee4fae18cf601a743556547c0 Mon Sep 17 00:00:00 2001 From: kalmar Date: Mon, 13 Mar 2017 10:28:49 +0100 Subject: [PATCH] Slightly faster algebra multiplication --- GroupAlgebras.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GroupAlgebras.jl b/GroupAlgebras.jl index fc72c7c..12ebdd2 100644 --- a/GroupAlgebras.jl +++ b/GroupAlgebras.jl @@ -61,12 +61,12 @@ end function algebra_multiplication{T<:Number}(X::AbstractVector{T}, Y::AbstractVector{T}, pm::Array{Int,2}) result = zeros(X) - for (i,x) in enumerate(X) - if x != 0 - for (j, index) in enumerate(pm[i,:]) - if Y[j] != 0 + for (j,y) in enumerate(Y) + if y != zero(T) + for (i, index) in enumerate(pm[:,j]) + if X[i] != zero(T) index == 0 && throw(ArgumentError("The product don't seem to belong to the span of basis!")) - result[index] += x*Y[j] + result[index] += X[i]*y end end end