From e93ec0c4221bac3fe8f9a24d8fe532920ccfd21b Mon Sep 17 00:00:00 2001 From: kalmar Date: Mon, 17 Apr 2017 15:23:36 +0200 Subject: [PATCH] add keyword for twisted product_matrix --- src/sdps.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sdps.jl b/src/sdps.jl index b8199c6..54f12d9 100644 --- a/src/sdps.jl +++ b/src/sdps.jl @@ -1,14 +1,18 @@ using JuMP import MathProgBase: AbstractMathProgSolver -function create_product_matrix{T}(basis::Vector{T}, limit) +function create_product_matrix{T}(basis::Vector{T}, limit; twisted=true) product_matrix = zeros(Int, (limit,limit)) basis_dict = Dict{T, Int}(x => i for (i,x) in enumerate(basis)) for i in 1:limit - x_inv::eltype(basis) = inv(basis[i]) + if twisted + x = inv(basis[i]) + else + x = basis[i] + end for j in 1:limit - w = x_inv*basis[j] + w = x*basis[j] product_matrix[i,j] = basis_dict[w] # index = findfirst(basis, w) # index ≠ 0 || throw(ArgumentError("Product is not supported on basis: $w")) @@ -18,6 +22,8 @@ function create_product_matrix{T}(basis::Vector{T}, limit) return product_matrix end +create_product_matrix{T}(basis::Vector{T}; twisted=twisted) = create_product_matrix(basis, length(basis); twisted=twisted) + function constraints_from_pm(pm, total_length) n = size(pm,1) constraints = constraints = [Array{Int,1}[] for x in 1:total_length]