toqito.matrices.comparison ========================== .. py:module:: toqito.matrices.comparison .. autoapi-nested-parse:: Computes comparison matrix. Module Contents --------------- .. py:function:: 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 [@WikiComparisonMatrix]. 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, \[ m_{ij} = \begin{cases} |a_{ij}|, & \text{if } i = j, \\ -|a_{ij}|, & \text{if } i \neq j. \end{cases} \] .. rubric:: Examples ```python exec="1" source="above" import numpy as np from toqito.matrices import comparison A = np.array([[2, -1], [3, 4]]) print(comparison(A)) ``` :raises ValueError: If the input matrix is not square. :param mat: The input square matrix. :returns: The comparison matrix of the input matrix.