qrisp.operators.qubit.QubitOperator.to_sparse_matrix#

QubitOperator.to_sparse_matrix(factor_amount=None)[source]#

Returns a scipy matrix representing the operator

\[O=\sum_i\alpha_i\bigotimes_{j=0}^{n-1}O_{ij}\]

where \(O_{ij}\in\{X,Y,Z,A,C,P_0,P_1,I\}\).

Parameters:
factor_amountint, optional

The amount of factors \(n\) to represent this matrix. The matrix will have the dimension \(2^n \times 2^n\), where n is the amount of factors. By default the minimal number \(n\) is chosen.

Returns:
scipy.sparse.csr_matrix

The sparse matrix representing the operator.