• https://me.yahoo.com
COST (GBP)
0.70
0.19
0

# Multiplication

Computes the product of two permutations.
Controller: CodeCogs

C++

## Multiplication

 std::vectormultiplication( int n int* p1 int* p2 )
If $\inline&space;&space;\sigma$ and $\inline&space;&space;\tau$ are permutations, given by

$\sigma&space;=&space;\left(&space;\begin{array}{cccc}&space;1&space;&&space;2&space;&&space;\ldots&space;&&space;n&space;\cr&space;\sigma(1)&space;&&space;\sigma(2)&space;&&space;\ldots&space;&&space;\sigma(n)&space;\end{array}&space;\right)$

and

$\tau&space;=&space;\left(&space;\begin{array}{cccc}&space;1&space;&&space;2&space;&&space;\ldots&space;&&space;n&space;\cr&space;\tau(1)&space;&&space;\tau(2)&space;&&space;\ldots&space;&&space;\tau(n)&space;\end{array}&space;\right)$

then the product $\inline&space;&space;\sigma&space;\circ&space;\tau$ is calculated using the following formula

$\sigma&space;\circ&space;\tau&space;=&space;\left(&space;\begin{array}{cccc}&space;1&space;&&space;2&space;&&space;\ldots&space;&&space;n&space;\cr&space;\sigma(\tau(1))&space;&&space;\sigma(\tau(2))&space;&&space;\ldots&space;&&space;\sigma(\tau(n))&space;\end{array}&space;\right)$

This function returns the result of the multiplication as a C++ vector object.

## Example:

#include <codecogs/maths/combinatorics/permutations/multiplication.h>
#include <iostream>
int main()
{
int sigma[5] = {5, 2, 1, 4, 3}, tau[5] = {3, 2, 5, 4, 1};
std::vector<int> result = Maths::Combinatorics::Permutations::multiplication(5, sigma, tau);
std::cout << "The multiplication of Sigma and Tau is: ";
std::cout << std::endl;
for (int i = 0; i < 5; i++)
std::cout << result[i] << " ";
std::cout << std::endl;
std::cout << "This proves one is the inverse of the other.";
std::cout << std::endl;
return 0;
}

## Output:

The multiplication of Sigma and Tau is:
1 2 3 4 5
This proves one is the inverse of the other.

## References:

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

### Returns

the product of the two permutations, stored as a C++ vector object

### 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.