Thanks for the code – would you be willing to contribute it under the MIT
license?

On Tue, Feb 10, 2015 at 9:21 AM, Dawid Crivelli <[email protected]> wrote:

> 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