Skip to main content

Module state

Module state 

Source
Expand description

SVG-first quantum-state visualization.

This module provides plotting routines for pure and mixed quantum states:

§Module Structure

§Examples

use cqlib_core::qis::Statevector;
use cqlib_core::visualization::{StatePlotOptions, plot_bloch_multivector};
use num_complex::Complex64;

let state = Statevector::from_state(
    1,
    vec![
        Complex64::new(1.0 / 2.0_f64.sqrt(), 0.0),
        Complex64::new(1.0 / 2.0_f64.sqrt(), 0.0),
    ],
).unwrap();
let svg = plot_bloch_multivector(&state, &StatePlotOptions::default()).unwrap();
assert!(svg.contains("<svg"));

Structs§

StatePlotOptions
Options shared by state-visualization backends.

Traits§

StateVisualizationSource
Core state types accepted by state visualization functions.

Functions§

local_bloch_vectors
Compute one reduced single-qubit Bloch vector for each qubit.
plot_bloch_multivector
Plot one reduced Bloch vector per qubit as SVG.
plot_bloch_vector
Plot a single Bloch vector as SVG.
plot_state_city
Plot real and imaginary density-matrix components as an SVG state-city view.
plot_state_paulivec
Plot Pauli-basis expectation values as an SVG bar chart.
render_state_plot_to_file
Render SVG markup to .svg or rasterized .png.
state_to_density_matrix
Convert a core state object into a row-major density matrix.