matrices.comparison¶
Computes comparison matrix.
Functions¶
|
Compute comparison matrix of a given square matrix. |
Module Contents¶
- matrices.comparison.comparison(mat)¶
Compute comparison matrix of a given square matrix.
This function computes the comparison matrix \(M(A)\) for a square matrix \(A\) as defined in [1]. For each entry, the diagonal entries are given by the absolute value of the original diagonal entries of \(A\), while the off-diagonal entries are given by minus the absolute value of the corresponding entries. In other words,
\[\begin{split}m_{ij} = \begin{cases} |a_{ij}|, & \text{if } i = j, \\ -|a_{ij}|, & \text{if } i \neq j. \end{cases}\end{split}\]Examples
import numpy as np from toqito.matrices import comparison A = np.array([[2, -1], [3, 4]]) print(comparison(A))
[[ 2. -1.] [-3. 4.]]
References
- Parameters:
mat (numpy.ndarray) – The input square matrix.
- Raises:
ValueError – If the input matrix is not square.
- Returns:
The comparison matrix of the input matrix.
- Return type:
numpy.ndarray