I have forgotten
my Password

Or login with:

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

Unrank

Returns the permutation of the given rank, as generated by the Permutation Class 2 component.
Controller: CodeCogs

Interface

C++

Unknown

 
std::vector<int> unrankunknownintn
intrank )
This function computes the permutation of given rank and size, as generated by the <em> Permutation Class 2 </em> component, but <em> without </em> generating all the previous permutations. This function may be used with the Maths/Combinatorics/Permutations/Rank component in order to give a method of recognizing certain permutations only by their rank number.

Example:

#include <codecogs/maths/combinatorics/permutations/unrank.h>
#include <iostream>
int main()
{
  std::cout << "The permutation of 10 elements and rank 124 is:";
  std::cout << std::endl;
  std::vector<int> result = Maths::Combinatorics::Permutations::unrank(10, 124);
  for (int i = 0; i < result.size(); i++)
    std::cout << result[i] << "  ";
  std::cout << std::endl;
  return 0;
}

Output:

The permutation of 10 elements and rank 124 is:
1  2  3  9  4  5  10  6  8  7

References:

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

Returns

the permutation of size n and given rank, as generated by the <em> Permutation Class 2 </em> component

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.