Linear Algebra

A number of linear algebra-related functions.

Matrices

toqito.matrices.clock(dim)

Produce clock matrix [WikClock].

toqito.matrices.cnot()

Produce the CNOT matrix [WikCNOT].

toqito.matrices.fourier(dim)

Generate the Fourier transform matrix [WikDFT].

toqito.matrices.gell_mann(ind[, is_sparse])

Produce a Gell-Mann operator [WikGM].

toqito.matrices.gen_gell_mann(ind_1, ind_2, dim)

Produce a generalized Gell-Mann operator [WikGM2].

toqito.matrices.gen_pauli(k_1, k_2, dim)

Produce generalized Pauli operator [WikGenPaul].

toqito.matrices.hadamard([n_param])

Produce a 2^{n_param} dimensional Hadamard matrix [WikHad].

toqito.matrices.iden(dim[, is_sparse])

Calculate the dim-by-dim identity matrix [WIKID].

toqito.matrices.pauli(ind[, is_sparse])

Produce a Pauli operator [WikPauli].

toqito.matrices.shift(dim)

Produce a dim-by-dim shift matrix [WikShift].

toqito.matrices.standard_basis(dim[, flatten])

Create standard basis of dimension dim.

Operations on Matrices and Vectors

toqito.matrix_ops.tensor(*args)

Compute the Kronecker tensor product [WikTensor].

toqito.matrix_ops.unvec(vector[, shape])

Perform the unvec operation on a vector to obtain a matrix [Rigetti2020].

toqito.matrix_ops.vec(mat)

Perform the vec operation on a matrix [WATVEC].

toqito.matrix_ops.inner_product(v1, v2)

Compute the inner product \(\langle v_1|v_2\rangle\) of two vectors [WikInner].

toqito.matrix_ops.outer_product(v1, v2)

Compute the outer product \(|v_1\rangle\langle v_2|\) of two vectors.

Properties of Matrices and Vectors

toqito.matrix_props.is_block_positive(mat[, ...])

Check if matrix is block positive [1]_.

toqito.matrix_props.is_commuting(mat_1, mat_2)

Determine if two linear operators commute with each other [WikCom].

toqito.matrix_props.is_density(mat)

Check if matrix is a density matrix [WikDensity].

toqito.matrix_props.is_diagonal(mat)

Determine if a matrix is diagonal [WikDiag].

toqito.matrix_props.is_hermitian(mat[, ...])

Check if matrix is Hermitian [WikHerm].

toqito.matrix_props.is_identity(mat[, rtol, ...])

Check if matrix is the identity matrix [WikIdentity].

toqito.matrix_props.is_idempotent(mat[, ...])

Check if matrix is the idempotent matrix [WikIdempotent].

toqito.matrix_props.is_normal(mat[, rtol, atol])

Determine if a matrix is normal [WikNormal].

toqito.matrix_props.is_orthonormal(vectors)

Check if the vectors are orthonormal.

toqito.matrix_props.is_permutation(mat)

Determine if a matrix is a permutation matrix [WikiPermutation].

toqito.matrix_props.is_positive_definite(mat)

Check if matrix is positive definite (PD) [WikPD].

toqito.matrix_props.is_projection(mat[, ...])

Check if matrix is a projection matrix [WikProj].

toqito.matrix_props.is_positive_semidefinite(mat)

Check if matrix is positive semidefinite (PSD) [WikPSD].

toqito.matrix_props.is_square(mat)

Determine if a matrix is square [WikSquare].

toqito.matrix_props.is_symmetric(mat[, ...])

Determine if a matrix is symmetric [WikSym].

toqito.matrix_props.is_unitary(mat[, rtol, atol])

Check if matrix is unitary [WikUnitary].

toqito.matrix_props.majorizes(a_var, b_var)

Determine if one vector or matrix majorizes another.

toqito.matrix_props.sk_operator_norm(mat[, ...])

Compute the S(k)-norm of a matrix [1]_.