FUNCTION
Inversion_Sequence
Computes the inversion sequence of a permutation.
Interface
#include <codecogs/maths/combinatorics/permutations/inversion_sequence.h>
using namespace Maths::Combinatorics::Permutations;
For a given permutation
(1)
the inversion sequence is defined as
(2)
with .
This function calculates the inversion sequence of a permutation based on the above formula and returns its value as a C++ vector object.
Returns
the inversion sequence of the given permutation
Example:
#include <codecogs/maths/combinatorics/permutations/inversion_sequence.h>
#include <iostream>
int main()
{
int sigma[5] = {3, 5, 1, 4, 2};
std::vector<int> result = Maths::Combinatorics::Permutations::inversion_sequence(5, sigma);
std::cout << "The inversion sequence of the Sigma permutation: ";
std::cout << std::endl;
for (int i = 0; i < 5; i++)
std::cout << result[i] << " ";
std::cout << std::endl;
return 0;
}
Output:
The inversion sequence of the Sigma permutation:
0 0 2 1 3
References
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html
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.