quairkit.qinfo.check

quairkit.qinfo.check.is_choi(op)
Check if the input op is a Choi operator of a physical operation.

Support batch input.

Parameters:
op : ndarray | Tensor

matrix form of the linear operation.

Returns:

Whether the input op is a valid quantum operation Choi operator. For batch input, return a boolean array with the same batch dimensions as input.

Return type:

bool | List[bool]

Note

The operation op is (default) applied to the second system.

quairkit.qinfo.check.is_density_matrix(rho, eps=1e-06)
Verify whether rho is a legal quantum density matrix

Support batch input

Parameters:
rho : ndarray | Tensor

density matrix candidate

eps : float | None

tolerance of error, default to be None i.e. no testing for data correctness

Returns:

determine whether rho is a PSD matrix with trace 1

Return type:

bool | List[bool]

quairkit.qinfo.check.is_hermitian(mat, eps=1e-06)
Verify whether mat is Hermitian.

Support batch input.

Parameters:
mat : ndarray | Tensor

hermitian candidate \(P\)

eps : float | None

tolerance of error

Returns:

determine whether \(P - P^\dagger = 0\) For batch input, return a boolean array with the same batch dimensions as input.

Return type:

bool | List[bool]

quairkit.qinfo.check.is_linear(func, info, input_dtype=None, eps=1e-05)

Check if the provided function ‘func’ is linear.

Parameters:
func : Callable[[Tensor | ndarray], Tensor | ndarray]

A callable function to be tested. This function should accept and return either a torch.Tensor or a numpy.ndarray.

info : List[int] | Callable[[], ndarray] | Callable[[], Tensor]

A parameter specifying the shape of the input for ‘func’. It can be a list of two integers (defining the shape of a tensor), a callable that returns a numpy.ndarray, or a callable that returns a torch.Tensor.

eps : float | None

An optional tolerance value used to determine if the function’s behavior is close enough to linear. Default value is 1e-6.

Returns:

True if ‘func’ behaves as a linear function within the specified tolerance ‘eps’; False otherwise.

Return type:

bool

Raises:

TypeError – If ‘func’ is not callable, does not accept a torch.Tensor or numpy.ndarray as input, or does not return a torch.Tensor or numpy.ndarray. If ‘info’ is not a valid type (not a list of integers or a callable returning a torch.Tensor or numpy.ndarray).

quairkit.qinfo.check.is_positive(mat, eps=1e-06)
Verify whether mat is a positive semi-definite matrix.

Support batch input.

Parameters:
mat : ndarray | Tensor

positive operator candidate \(P\)

eps : float | None

tolerance of error

Returns:

determine whether \(P\) is Hermitian and eigenvalues are non-negative For batch input, return a boolean array with the same batch dimensions as input.

Return type:

bool | List[bool]

quairkit.qinfo.check.is_povm(set_op, eps=1e-06)

Check if a set of operators forms a positive operator-valued measure (POVM).

Parameters:
set_op : Tensor | ndarray

A set of operators indexed by the first dimension

eps : float | None

An optional tolerance value. Default value is 1e-6.

Returns:

whether the operators form a POVM.

Return type:

bool | List[bool]

quairkit.qinfo.check.is_projector(mat, eps=1e-06)
Verify whether mat is a projector.

Support batch input.

Parameters:
mat : ndarray | Tensor

projector candidate \(P\)

eps : float | None

tolerance of error

Returns:

determine whether \(PP - P = 0\) For batch input, return a boolean array with the same batch dimensions as input.

Return type:

bool | List[bool]

quairkit.qinfo.check.is_ppt(density_op)
Check if the input quantum state is PPT.

Support batch input.

Parameters:
density_op : ndarray | Tensor | State

Density matrix form of the quantum state.

Returns:

Whether the input quantum state is PPT. For batch input, return a boolean array with the same batch dimensions as input.

Return type:

bool | List[bool]

quairkit.qinfo.check.is_pvm(set_op, eps=1e-06)

Check if a set of operators forms a projection-valued measure (PVM).

Parameters:
set_op : Tensor | ndarray

A set of operators indexed by the first dimension

eps : float | None

An optional tolerance value. Default value is 1e-6.

Returns:

True if the operators form a PVM; otherwise, False.

Return type:

bool or List[bool]

quairkit.qinfo.check.is_state_vector(vec, eps=1e-06)
Verify whether vec is a legal quantum state vector.

Support batch input.

Parameters:
vec : ndarray | Tensor

state vector candidate \(x\)

eps : float | None

tolerance of error, default to be None i.e. no testing for data correctness

Returns:

determine whether \(x^\dagger x = 1\)

Return type:

bool | List[bool]

quairkit.qinfo.check.is_unitary(mat, eps=0.0001)
Verify whether mat is a unitary.

Support batch input.

Parameters:
mat : ndarray | Tensor

unitary candidate \(P\)

eps : float | None

tolerance of error

Returns:

determine whether \(PP^\dagger - I = 0\) For batch input, return a boolean array with the same batch dimensions as input.

Return type:

bool | List[bool]