lib/more_math/permutation.rb
# Returns the signum of this Permutation instance.
# It's -1 if this permutation is odd and 1 if it's
# an even permutation.
#
# A permutation is odd if it can be represented by an odd number of
# transpositions (cycles of length 2), or even if it can be represented of
# an even number of transpositions.
Returns the signum of this Permutation instance.
It's -1 if this permutation is odd and 1 if it's
an even permutation.

A permutation is odd if it can be represented by an odd number of
transpositions (cycles of length 2), or even if it can be represented of
an even number of transpositions.
Returns the signum of this Permutation instance . It ' s - 1 if this permutation is odd and 1 if it ' s an even permutation . A permutation is odd if it can be represented by an odd number of transpositions ( cycles of length 2 ) or even if it can be represented of an even number of transpositions .
def signum
      s = 1
      cycles.each do |c|
        c.size % 2 == 0 and s *= -1
      end
      s
    end
def signum s = 1 cycles . each do | c | c . size % 2 == 0 and s *= - 1 end s end
Returns the signum of this Permutation instance.
Returns the signum of this Permutation instance .