Assigns a permutation matrix from a vector of integral indices of elements within each column of a matrix.
- Template Parameters
-
ValueType | A type of a matrix element. |
- Parameters
-
[in,out] | column_matrix | A pointer to a two dimensional column-major square matrix of size nXn , to assign the permutation matrix to. |
| n | A number of columns and rows of the matrix pointed to by column_matrix . |
[in] | permutation_indices | An array of integral indices of non-zero elements within each column of the constructed permutation matrix. All elements of the array are assumed unique and their values are assumed less than n , though these preconditions are not validated by the function. |
| scaling | A value assigned to non-zero elements of the permutation matrix. For a strictly permutation matrix the value of scaling should have the semantics of 1 (multiplicative identity). |
- Exceptions
-
Any | exception thrown by default construction, copy- or move-construction of ValueType elements. |
The function uses a map \(f: \mathbb{N}_0 \to T^n\), where \(T\) is a set of values implemented by the type ValueType
, to produce vectors to constitute columns of the resulting matrix, such that each ith column will have one permutation_indices[i]
-th scalar copy-assigned from scaling
, and other elements of that column will be assigned from default-constructed elements of the type ValueType
. Then the resulting matrix, elements of which are sequentially assigned to column_matrix
, will be \(M=\left(\begin{array}{cccc} f(p_0) & f(p_1) & \cdots & f(p_{n-1}) \end{array}\right)\), where pi == permutation_indices[i]
.
The resulting matrix is assigned, element by element, to column_matrix
, that is assignment operator is invoked for each of the elements of the resulting matrix. To construct a new matrix in uninitialized space, rather than assign it, use construct_permutation_scaling_matrix.