Difference between revisions of "Perm inv"

From QETLAB
Jump to navigation Jump to search
(Created page with "{{Function |name=perm_inv |desc=Computes the inverse of a permutation |upd=November 28, 2012 |v=1.00 |helper=1}} <tt>'''perm_inv'''</tt> is a function th...")
 
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
|name=perm_inv
 
|name=perm_inv
 
|desc=Computes the inverse of a permutation
 
|desc=Computes the inverse of a permutation
 +
|rel=[[perm_sign]]
 +
|cat=[[List of functions#Helper_functions|Helper functions]]
 
|upd=November 28, 2012
 
|upd=November 28, 2012
|v=1.00
+
|v=0.50
 
|helper=1}}
 
|helper=1}}
 
<tt>'''perm_inv'''</tt> is a [[List of functions|function]] that computes the [http://mathworld.wolfram.com/InversePermutation.html inverse of a permutation].
 
<tt>'''perm_inv'''</tt> is a [[List of functions|function]] that computes the [http://mathworld.wolfram.com/InversePermutation.html inverse of a permutation].
Line 16: Line 18:
 
===Small examples===
 
===Small examples===
 
The identity permutation is its own inverse:
 
The identity permutation is its own inverse:
<pre>
+
<syntaxhighlight>
 
>> perm_inv(1:4)
 
>> perm_inv(1:4)
  
Line 22: Line 24:
  
 
     1    2    3    4
 
     1    2    3    4
</pre>
+
</syntaxhighlight>
  
 
To compute the inverse of the permutation on [http://mathworld.wolfram.com/InversePermutation.html this MathWorld page], we can use the following line of code:
 
To compute the inverse of the permutation on [http://mathworld.wolfram.com/InversePermutation.html this MathWorld page], we can use the following line of code:
<pre>
+
<syntaxhighlight>
 
>> perm_inv([3,8,5,10,9,4,6,1,7,2])
 
>> perm_inv([3,8,5,10,9,4,6,1,7,2])
  
Line 31: Line 33:
  
 
     8    10    1    6    3    7    9    2    5    4
 
     8    10    1    6    3    7    9    2    5    4
</pre>
+
</syntaxhighlight>
 +
 
 +
{{SourceCode|name=perm_inv|helper=1}}

Latest revision as of 16:08, 29 September 2014

perm_inv
Computes the inverse of a permutation

Other toolboxes required none
Related functions perm_sign
Function category Helper functions
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_inv is a function that computes the inverse of a permutation.

Syntax

  • PI = perm_inv(PERM)

Argument descriptions

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

Examples

Small examples

The identity permutation is its own inverse:

>> perm_inv(1:4)

ans =

     1     2     3     4

To compute the inverse of the permutation on this MathWorld page, we can use the following line of code:

>> perm_inv([3,8,5,10,9,4,6,1,7,2])

ans =

     8    10     1     6     3     7     9     2     5     4

Source code

Click here to view this function's source code on github.