paddle_quantum.operator.operator

The source file of the class for the special quantum operator.

class paddle_quantum.operator.operator.ResetState

Bases: Operator

The class to reset the quantum state. It will be implemented soon.

forward(*inputs, **kwargs)

The forward function.

Returns:

NotImplemented.

class paddle_quantum.operator.operator.PartialState

Bases: Operator

The class to obtain the partial quantum state. It will be implemented soon.

forward(*inputs, **kwargs)

The forward function.

Returns:

NotImplemented.

class paddle_quantum.operator.operator.Collapse(qubits_idx='full', num_qubits=None, desired_result=None, if_print=False, measure_basis='z')

Bases: Operator

The class to compute the collapse of the quantum state.

Parameters:
  • qubits_idx (Iterable[int] | int | str) – list of qubits to be collapsed. Defaults to 'full'.

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • desired_result (int | str) – The desired result you want to collapse. Defaults to None meaning randomly choose one.

  • if_print (bool) – whether print the information about the collapsed state. Defaults to False.

  • measure_basis (Iterable[Tensor] | str) – The basis of the measurement. The quantum state will collapse to the corresponding eigenstate.

Raises:

NotImplementedError – If the basis of measurement is not z. Other bases will be implemented in future.

Note

When desired_result is None, Collapse does not support gradient calculation

forward(state)

Compute the collapse of the input state.

Parameters:

state (State) – The input state, which will be collapsed

Returns:

The collapsed quantum state.

Return type:

State