paddle_quantum.visual

The visualization function in paddle quantum.

paddle_quantum.visual.plot_state_in_bloch_sphere(state, show_arrow=False, save_gif=False, filename=None, view_angle=None, view_dist=None, set_color=None)

Plot the input quantum state on the Bloch sphere.

Parameters:
  • state (List[State]) – List of the input quantum states in the state vector form or the density matrix form.

  • show_arrow (bool | None) – Whether to show an arrow for each vector. Defaults to False.

  • save_gif (bool | None) – Whether to store the gif. Defaults to False.

  • filename (str | None) – The name of the gif file to be stored. Defaults to None.

  • view_angle (tuple | list | None) – View angle. The first element is the angle [0-360] to the x-y plane, and the second element is the angle [0-360] to the x-z plane. Defaults to (30, 45).

  • view_dist (int | None) – View distance. Defaults to 7.

  • set_color (str | None) – To set the specified color, consult the cmap table. Defaults to "red to black gradient".

paddle_quantum.visual.plot_multi_qubits_state_in_bloch_sphere(state, which_qubits=None, show_arrow=False, save_gif=False, save_pic=True, filename=None, view_angle=None, view_dist=None, set_color='#0000FF')

Displaying the quantum state on the Bloch sphere which has multi qubits.

Parameters:
  • state (State) – List of the input quantum states in the state vector form or the density matrix form.

  • which_qubits (List[int] | None) – Index of qubits to display, default to be fully displayed.

  • show_arrow (bool | None) – Whether to show an arrow for each vector. Default is False.

  • save_gif (bool | None) – Whether to store the gif. Default is False.

  • save_pic (bool | None) – Whether to store the picture. Default is True.

  • filename (str | None) – The name of the picture to be stored. Defaults to None.

  • view_angle (tuple | list | None) – View angle. The first element is the angle [0-360] to the x-y plane, and the second element is the angle [0-360] to the x-z plane. Defaults to (30, 45).

  • view_dist (int | None) – View distance. Default is 7.

  • set_color (str | None) – To set the specified color, consult the cmap table. Default is "blue".

paddle_quantum.visual.plot_rotation_in_bloch_sphere(init_state, rotating_angle, show_arrow=False, save_gif=False, filename=None, view_angle=None, view_dist=None, color_scheme=None)

Plot the rotation starting from the initial quantum state on the Bloch sphere.

Parameters:
  • init_state (State) – Initial quantum state in the state vector form or the density matrix form.

  • rotating_angle (List[Tensor]) – Rotation angle [theta, phi, lam].

  • show_arrow (bool | None) – Whether to show an arrow for each vector. Defaults to False.

  • save_gif (bool | None) – Whether to store the gif. Defaults to False.

  • filename (str | None) – The name of the gif file to be stored. Defaults to None.

  • view_angle (tuple | list | None) – The first element is the angle [0-360] to the x-y plane, and the second element is the angle [0-360] to the x-z plane. Defaults to None.

  • view_dist (int | None) – View distance. Default is 7.

  • color_scheme (List[str] | None) – initial color, trace color, and end color, respectively. To set the specified color, consult the cmap table. Default is “red”.

paddle_quantum.visual.plot_density_matrix_graph(density_matrix, size=0.3)

Density matrix visualization tools

Parameters:
  • density_matrix (State) – The state vector or density matrix of quantum state with multi qubits, requiring the number of qubits greater than 1

  • size (float | None) – Bar width, between 0 and 1, default is 0.3.

Raises:
  • TypeError – Expected density_matrix to be np.ndarray or paddle.Tensor or paddle_quantum.State

  • ValueError – Expected density matrix dim0 equal to dim1