• https://me.yahoo.com
COST (GBP)
0.37
0.80
0

# Rank

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

C++

## Rank

 intrank( int n int* p )
This function calculates at which call the Permutation Class 2 component would generate the given permutation. The value of the rank will be between 1 and $\inline&space;n!$. This function may be used with the Maths/Combinatorics/Permutations/Unrank component in order to give a method of recognizing certain permutations only by their rank number.

## Example:

```#include <codecogs/maths/combinatorics/permutations/rank.h>
#include <iostream>
int main()
{
int sigma[3] = {2, 3, 1};
std::cout << "The rank of the Sigma permutation is: ";
std::cout << Maths::Combinatorics::Permutations::rank(3, sigma) << std::endl;
return 0;
}```

## Output:

`The rank of the Sigma permutation is: 5`

## References:

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

### Parameters

 n the size of the permutation p the actual permutation stored as an array

### Returns

the rank of the given permutation, 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.

Last Modified: 31 Dec 11 @ 22:25     Page Rendered: 2022-03-14 15:22:33