I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
COST (GBP)
this unit 1.04
sub units 0.19
+
0

Inversion Sequence

Computes the inversion sequence of a permutation.
Controller: CodeCogs

add cart

Dependents

Info

Interface

C++

Inversion Sequence

 
std::vector<int>inversion_sequenceintn
int*p )
For a given permutation

the inversion sequence ( \alpha ) is defined as

with \alpha(1) = 0.

This function calculates the inversion sequence of a permutation based on the above formula and returns its value as a C++ vector object.

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

Returns

the inversion sequence of the given permutation

Authors

Lucian Bentea (August 2005)
Source Code

Source code is available when you buy a Commercial licence.

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