Ulam Distance
Computes the Ulam metric distance of two permutations.
Controller: CodeCogs
Dependents
Interface
C++
Ulam Distance
intulam_distance( | int | n | |
int* | a | ||
int* | b | )[inline] |
References:
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.htmlExample 1
#include <codecogs/maths/combinatorics/permutations/ulam_distance.h> #include <iostream> int main() { int sigma[5] = {1, 2, 3, 4, 5}, tau[5] = {5, 2, 1, 4, 3}, distance = Maths::Combinatorics::Permutations::ulam_distance(5, sigma, tau); std::cout << "The Ulam metric distance of Sigma and Tau is: "; std::cout << std::endl << distance << std::endl; return 0; }
Output:The Ulam metric distance of Sigma and Tau is: 3
Parameters
n the size of the permutations a the first permutation b the second permutation
Returns
- the value of the Ulam metric distance between a and b
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.