Separate GroupAlgebras logic from multiplication

This commit is contained in:
kalmar 2017-01-13 17:59:01 +01:00
parent e6f3051d83
commit 0cf908ee13
1 changed files with 15 additions and 14 deletions

View File

@ -59,25 +59,26 @@ end
(-)(X::GroupAlgebraElement) = GroupAlgebraElement(-X.coefficients, X.product_matrix) (-)(X::GroupAlgebraElement) = GroupAlgebraElement(-X.coefficients, X.product_matrix)
(-)(X::GroupAlgebraElement, Y::GroupAlgebraElement) = add(X,-Y) (-)(X::GroupAlgebraElement, Y::GroupAlgebraElement) = add(X,-Y)
function group_star_multiplication{T<:Number}(X::GroupAlgebraElement{T}, function algebra_multiplication{T<:Number}(X::Vector{T}, Y::Vector{T}, pm::Array{Int,2})
Y::GroupAlgebraElement{T}) result = zeros(X)
X.product_matrix == Y.product_matrix || ArgumentError( for (i,x) in enumerate(X)
"Elements don't seem to belong to the same Group Algebra!")
result = zeros(X.coefficients)
for (i,x) in enumerate(X.coefficients)
if x != 0 if x != 0
for (j,y) in enumerate(Y.coefficients) for (j, index) in enumerate(pm[i,:])
if y != 0 if Y[j] != 0
index = X.product_matrix[i,j] index == 0 && throw(ArgumentError("The product don't seem to belong to the span of basis!"))
if index == 0 result[index] += x*Y[j]
throw(ArgumentError("The product don't seem to belong to the span of basis!"))
else
result[index]+= x*y
end
end end
end end
end end
end end
return result
end
function group_star_multiplication{T<:Number}(X::GroupAlgebraElement{T},
Y::GroupAlgebraElement{T})
X.product_matrix == Y.product_matrix || ArgumentError(
"Elements don't seem to belong to the same Group Algebra!")
result = algebra_multiplication(X.coefficients, Y.coefficients, X.product_matrix)
return GroupAlgebraElement(result, X.product_matrix) return GroupAlgebraElement(result, X.product_matrix)
end end