Constructs a permutation matrix as a two-dimensional array of columns of elements from a vector of integral indices of elements within each column of a matrix.
- Template Parameters
-
ValueType | A type of a matrix element. |
- Parameters
-
[out] | column_matrix | A pointer to a buffer, in which elements of the resulting permutation matrix are constructed element-by-element. This buffer must be sufficient in size to hold \(n^2\) elements of the type ValueType in order to hold a two-dimensional array of column-major square matrix of size nXn . |
| n | A number of columns and rows of the resulting permutation matrix constructed in the buffer addressed 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, 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 permutation matrix, such that each ith column will have one permutation_indices[i]
-th scalar copy-constructed in place addressed by &column_matrix[i * n + permutation_indices[i]]
from scaling
, and the other elements of that column will be default-constructed. Then the resulting matrix, elements of which are sequentially constructed in the place of 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 elements of the resulting permutation matrix are sequentially constructed in the uninitialized buffer pointed to by column_matrix
such that neither destructors of existing data nor any assignment takes place. In order to properly replace elements of an existing matrix with a permutation matrix, use set_permutation_scaling_matrix.