Perm sign

From QETLAB
Revision as of 13:29, 22 November 2012 by Nathaniel (talk | contribs) (Created page with "{{Function |name=perm_sign |desc=Computes the sign of a permutation |upd=November 21, 2012 |v=1.00 |helper=1}} <tt>'''perm_sign'''</tt> is a function tha...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
perm_sign
Computes the sign of a permutation

Other toolboxes required none
This is a helper function that only exists to aid other functions in QETLAB. If you are an end-user of QETLAB, you likely will never have a reason to use this function.

perm_sign is a function that computes the sign a permutation. The output of the function is either 1, indicating the permutation is even, or -1, indicating the permutation is odd.

Syntax

  • SGN = perm_sign(PERM)

Argument descriptions

  • PERM: A vector containing a permutation of the integers 1, 2, ..., n.

Examples

The identity permutation is even:

>> perm_sign(1:4)

ans =

     1

The permutation that transposes 3 and 4 is odd:

>> perm_sign([1,2,4,3])

ans =

    -1