Sign
Calculates the sign of the given permutation.
Controller: CodeCogs
Contents
Dependents
Interface
C++
Sign
intsign( | int | n | |
int* | p | ) |
Example:
#include <codecogs/maths/combinatorics/permutations/sign.h> #include <iostream> int main() { int alpha[5] = {4, 3, 5, 1, 2}; std::cout << "The sign of the Alpha permutation is: "; std::cout << Maths::Combinatorics::Permutations::sign(5, alpha) << std::endl; return 0; }
Output:
The sign of the Alpha permutation is: -1
References:
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.htmlParameters
n the size of the permutation p the actual permutation stored as an array
Returns
- the sign of the given permutation
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.