better use of findfirst in create_product_matrix
This commit is contained in:
parent
239521f159
commit
95618eb0f9
|
@ -45,18 +45,13 @@ function create_product_matrix(basis::Array{Array{Float64,2},1}, limit::Int)
|
||||||
for i in 1:limit
|
for i in 1:limit
|
||||||
x_inv = inv(basis[i])
|
x_inv = inv(basis[i])
|
||||||
for j in 1:limit
|
for j in 1:limit
|
||||||
w::Array{Float64,2} = x_inv*basis[j]
|
w = x_inv*basis[j]
|
||||||
|
|
||||||
function f(x::Array{Float64,2})
|
index = findfirst(basis, w)
|
||||||
if x == w
|
if 0 < index ≤ limit
|
||||||
return true
|
product_matrix[i,j] = index
|
||||||
else
|
push!(constraints[index],[i,j])
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
index = findfirst(f, basis)
|
|
||||||
product_matrix[i,j] = index
|
|
||||||
push!(constraints[index],[i,j])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return product_matrix, constraints
|
return product_matrix, constraints
|
||||||
|
|
Loading…
Reference in New Issue