mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2025-01-13 06:47:32 +01:00
generic create_product_matrix function
This commit is contained in:
parent
9c10c2da76
commit
7f707e60a0
@ -12,26 +12,18 @@ function products{T}(U::AbstractVector{T}, V::AbstractVector{T})
|
|||||||
return unique(result)
|
return unique(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function create_product_matrix(basis, limit)
|
||||||
function create_product_matrix(basis::Array{Array{Float64,2},1}, limit)
|
|
||||||
|
|
||||||
product_matrix = zeros(Int, (limit,limit))
|
product_matrix = zeros(Int, (limit,limit))
|
||||||
constraints = [Array{Int,1}[] for x in 1:length(basis)]
|
|
||||||
|
|
||||||
for i in 1:limit
|
for i in 1:limit
|
||||||
x_inv = inv(basis[i])
|
x_inv::eltype(basis) = inv(basis[i])
|
||||||
# info("$i of $limit")
|
|
||||||
for j in 1:limit
|
for j in 1:limit
|
||||||
w = x_inv*basis[j]
|
w = x_inv*basis[j]
|
||||||
|
|
||||||
index = findfirst(basis, w)
|
index = findfirst(basis, w)
|
||||||
if 0 < index ≤ limit
|
index ≠ 0 || throw(ArgumentError("Product is not supported on basis: $w"))
|
||||||
product_matrix[i,j] = index
|
product_matrix[i,j] = index
|
||||||
push!(constraints[index],[i,j])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return product_matrix, constraints
|
return product_matrix
|
||||||
end
|
end
|
||||||
|
|
||||||
function constraints_from_pm(pm, total_length=maximum(pm))
|
function constraints_from_pm(pm, total_length=maximum(pm))
|
||||||
|
Loading…
Reference in New Issue
Block a user