I have forgotten

• https://me.yahoo.com
COST (GBP)
0.50
0.19
0

# inverse

Calculates the inverse of the given permutation.
Controller: CodeCogs
Contents

C++

## Inverse

 std::vectorinverse( int n int* p )
The inverse of a permutation
$\sigma&space;=&space;\left(&space;\begin{array}{cccc}&space;1&space;&&space;2&space;&&space;\ldots&space;&&space;n&space;\cr&space;\sigma(1)&space;&&space;\sigma(2)&space;&&space;\ldots&space;&&space;\sigma(n)&space;\end{array}&space;\right)$
is a permutation $\inline&space;\tau$ such that
$\sigma&space;\circ&space;\tau&space;=&space;\tau&space;\circ&space;\sigma&space;=&space;\left(&space;\begin{array}{cccc}&space;1&space;&&space;2&space;&&space;\ldots&space;&&space;n&space;\cr&space;1&space;&&space;2&space;&&space;\ldots&space;&&space;n&space;\end{array}&space;\right)$
where $\inline&space;\sigma&space;\circ&space;\tau$ represents multiplication. This function searches for the permutation $\inline&space;\tau$ with the property stated above and returns it as a C++ vector object.

## References:

SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

### Example 1

#include <codecogs/maths/combinatorics/permutations/inverse.h>
#include <iostream>
int main()
{
int sigma[5] = {5, 2, 1, 4, 3};
std::vector<int> result = Maths::Combinatorics::Permutations::inverse(5, sigma);
std::cout << "The inverse of the Sigma permutation is: ";
std::cout << std::endl;
for (int i = 0; i < 5; i++)
std::cout << result[i] << " ";
std::cout << std::endl;
return 0;
}
Output:
The inverse of the Sigma permutation is:
3 2 5 4 1

### Returns

the inverse of the given permutation p

### Authors

Lucian Bentea (August 2005)
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.