Permutes



Synonyms for permutes include changes, alters, modifies, adjusts, amends, edits, molds, redesigns, revamps and revises. Find more similar words at wordhippo.com! Permeate definition, to pass into or through every part of: Bright sunshine permeated the room.

  1. Permutest
  2. What Is The Mean Of A Permutation
  3. Permits
< cpp‎ | algorithm
C++
Language
Standard Library Headers
Freestanding and hosted implementations
Named requirements
Language support library
Concepts library(C++20)
Diagnostics library
Utilities library
Strings library
Containers library
Iterators library
Ranges library(C++20)
Algorithms library
Numerics library
Localizations library
Input/output library
Filesystem library(C++17)
Regular expressions library(C++11)
Atomic operations library(C++11)
Thread support library(C++11)
Technical Specifications
Algorithm library
Constrained algorithms and algorithms on ranges(C++20)
Constrained algorithms: std::ranges::copy, std::ranges::sort, ...
Execution policies (C++17)
Non-modifying sequence operations
(C++11)(C++11)(C++11)
(C++17)
(C++11)
(C++20)

Modifying sequence operations
(C++11)
(C++11)
(C++11)
(C++11)
(C++20)(C++20)
(C++17)

(until C++17)

(C++11)

Operations on uninitialized storage
(C++17)
(C++17)
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

(C++17)
(C++17)
(C++17)

(C++20)
Partitioning operations
(C++11)
Sorting operations
(C++11)
(C++11)

Binary search operations
Set operations (on sorted ranges)

Heap operations
(C++11)
(C++11)
Minimum/maximum operations
(C++11)
(C++11)
Permutations
(C++11)
Numeric operations
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

(C++17)
(C++17)
C library
Defined in header <algorithm>
(1)
template<class BidirIt >
bool next_permutation( BidirIt first, BidirIt last );
(until C++20)
template<class BidirIt >
constexprbool next_permutation( BidirIt first, BidirIt last );
(since C++20)
(2)
template<class BidirIt, class Compare >
bool next_permutation( BidirIt first, BidirIt last, Compare comp );
(until C++20)
template<class BidirIt, class Compare >
constexprbool next_permutation( BidirIt first, BidirIt last, Compare comp );
(since C++20)

Permutes the range [first, last) into the next permutation, where the set of all permutations is ordered lexicographically with respect to operator< or comp. Returns true if such a 'next permutation' exists; otherwise transforms the range into the lexicographically first permutation (as if by std::sort(first, last, comp)) and returns false.

[edit]Parameters

first, last - the range of elements to permute
comp - comparison function object (i.e. an object that satisfies the requirements of Compare) which returns ​true if the first argument is less than the second.

The signature of the comparison function should be equivalent to the following:

bool cmp(const Type1 &a, const Type2 &b);

While the signature does not need to have const&, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) Type1 and Type2 regardless of value category (thus, Type1 & is not allowed, nor is Type1 unless for Type1 a move is equivalent to a copy(since C++11)).
The types Type1 and Type2 must be such that an object of type BidirIt can be dereferenced and then implicitly converted to both of them.​

Type requirements
-BidirIt must meet the requirements of ValueSwappable and LegacyBidirectionalIterator.

[edit]Return value

true if the new permutation is lexicographically greater than the old. false if the last permutation was reached and the range was reset to the first permutation.

[edit]Exceptions

Any exceptions thrown from iterator operations or the element swap.

[edit]Complexity

At most N/2 swaps, where N =std::distance(first, last). Averaged over the entire sequence of permutations, typical implementations use about 3 comparisons and 1.5 swaps per call.

[edit]Possible implementation

Permutes

[edit]Example

The following code prints all three permutations of the string 'aba'

Output:

[edit]See also

(C++11)
determines if a sequence is a permutation of another sequence
(function template)[edit]
generates the next smaller lexicographic permutation of a range of elements
(function template)[edit]
(C++20)
generates the next greater lexicographic permutation of a range of elements
(niebloid)[edit]
Retrieved from 'https://en.cppreference.com/mwiki/index.php?title=cpp/algorithm/next_permutation&oldid=126997'
PermuteSystems
Permutes subsystems within a state or operator
Other toolboxes required none
Related functionsPermutationOperator
Swap
SwapOperator
Function categoryPermutations and symmetry of subsystems

PermuteSystems is a function that allows the user to permute the order of the subsystems underlying a quantum state or operator that is defined on the tensor product of 2 or more subsystems. It works with full and sparse numeric matrices as well as symbolic matrices.

  • 3Examples
Permutes

Syntax

  • PX = PermuteSystems(X,PERM)
  • PX = PermuteSystems(X,PERM,DIM)
  • PX = PermuteSystems(X,PERM,DIM,ROW_ONLY)
  • PX = PermuteSystems(X,PERM,DIM,ROW_ONLY,INV_PERM)

Argument Descriptions

Permutest

  • X: a vector (e.g., a pure quantum state) or a matrix to have its subsystems permuted
  • PERM: a permutation vector (i.e., a permutation of the vector 1:n)
  • DIM (optional, by default has all subsystems of equal dimension): A specification of the dimensions of the subsystems that X lives on. DIM can be provided in one of two ways:
    • If $X in M_{n_1} otimes cdots otimes M_{n_p}$ then DIM should be a row vector containing the dimensions (i.e., DIM = [n_1, ..., n_p]).
    • If the subsystems aren't square (i.e., $X in M_{m_1, n_1} otimes cdots otimes M_{m_p, n_p}$) then DIM should be a matrix with two rows. The first row of DIM should contain the row dimensions of the subsystems (i.e., the mi's) and its second row should contain the column dimensions (i.e., the ni's). In other words, you should set DIM = [m_1, ..., m_p; n_1, ..., n_p].
  • ROW_ONLY (optional, default 0): If set equal to 1, only the rows of X are permuted (this is equivalent to multiplying X on the left by PermutationOperator(DIM,PERM)). If equal to 0, both the rows and columns of X are permuted (this is equivalent to multiplying X on both the left and right by the permutation operator).
  • INV_PERM (optional, default 0): If equal to 0, this argument has no effect. If equal to 1, the subsystems are permuted according to the inverse of PERM rather than PERM itself.

Examples

All subsystems of equal dimension

In cases when all subsystems have the same dimension, most arguments can be omitted. Let's start with a matrix $X in M_2 otimes M_2$:

If we want to permute the two subsystems, we can call PermuteSystems with the permutation vector PERM = [2,1] (though if your needs are as simple as this, you may be better off using the Swap function):

Similarly, the following code acts on a matrix $X in M_A otimes M_B otimes M_C$ (where each subsystem has dimension 2) and outputs a matrix representation in the standard basis of $M_B otimes M_C otimes M_A$:

What Is The Mean Of A Permutation

Source code

Click on 'expand' to the right to view the MATLAB source code for this function.

Permits

Retrieved from 'http://www.qetlab.com/wiki/index.php?title=PermuteSystems&oldid=528'