FUNCTION
inverse
Calculates the inverse of the given permutation.
You're viewing an older version of this page (#1149). View the current version.
Interface
#include <codecogs/maths/combinatorics/permutations/inverse.h>
using namespace Maths::Combinatorics::Permutations;
The inverse of a permutation
(1)
is a permutation such that
(2)
where represents multiplication. This function searches for the permutation
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 1Returns
the inverse of the given permutation p
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.