Expand description
SVG-first quantum-state visualization.
This module provides plotting routines for pure and mixed quantum states:
plot_bloch_vector: render one Bloch vectorplot_bloch_multivector: render one reduced Bloch vector per qubitplot_state_city: render real/imaginary density-matrix componentsplot_state_paulivec: render Pauli-basis expectation values
§Module Structure
StateVisualizationSource: adapter trait for core QIS state typesStatePlotOptions: styling and layout optionsstate_to_density_matrix: normalize QIS states into density matriceslocal_bloch_vectors: compute reduced single-qubit Bloch vectors
§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§
- State
Plot Options - Options shared by state-visualization backends.
Traits§
- State
Visualization Source - 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
.svgor rasterized.png. - state_
to_ density_ matrix - Convert a core state object into a row-major density matrix.