From 95618eb0f9a0c4cd3bf0eb8cfad5ec1971c0fd95 Mon Sep 17 00:00:00 2001 From: kalmar Date: Fri, 13 Jan 2017 18:02:34 +0100 Subject: [PATCH] better use of findfirst in create_product_matrix --- property(T).jl | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/property(T).jl b/property(T).jl index a3bb0cd..3bac2c5 100644 --- a/property(T).jl +++ b/property(T).jl @@ -45,18 +45,13 @@ function create_product_matrix(basis::Array{Array{Float64,2},1}, limit::Int) for i in 1:limit x_inv = inv(basis[i]) for j in 1:limit - w::Array{Float64,2} = x_inv*basis[j] + w = x_inv*basis[j] - function f(x::Array{Float64,2}) - if x == w - return true - else - return false - end + index = findfirst(basis, w) + if 0 < index ≤ limit + product_matrix[i,j] = index + push!(constraints[index],[i,j]) end - index = findfirst(f, basis) - product_matrix[i,j] = index - push!(constraints[index],[i,j]) end end return product_matrix, constraints