Interface
#include <codecogs/maths/combinatorics/permutations/unrank.h>
using namespace Maths::Combinatorics::Permutations;
| std::vector<int> unrank | unknown (int n, int rank)
Returns the permutation of the given rank, as generated by the Permutation Class 2 component. |
Use the following HTML code to embed the calculators within other websites:
Unknown
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.