I have a short code for checking the sign of a permutation for personal 
use. It's O(L^2) where L is the length of the permutation vector, but it's 
perfectly fine for L in the few tens range.

function sign{T<:Integer}(perm::AbstractVector{T})
    L = length(perm)
    crosses = 0
    for i = 1:L
        for j = i+1 : L
            crosses += perm[j] < perm[i]
        end
    end
    return iseven(crosses) ? 1 : -1    
end


Reply via email to