Skip to main content

caroli_walk/
lib.rs

1//! Discrete-time quantum walks with spins: a walker jumps between the nodes of a graph and
2//! interacts with spins sitting on its edges (K. Sellapillay and A. D. Verga, "Quantum walk on a
3//! graph of spins: magnetism and entanglement", Phys. Rev. E 103, 032123 (2021)).
4//!
5//! The basis is `|x c s⟩`: node `x`, color `c` (one per edge at `x`: the half-edges of the
6//! node), spin configuration `s`. One step is `U = V(J) M C` ([`SpinWalk`]). The Hilbert space
7//! has dimension `2|E| · 2^|E|`, about 2·10⁷ for the 19-node ring.
8//!
9//! The state is stored half-edge by half-edge with the spin configuration fastest, so each part
10//! of a step is one sweep over memory: the coin pairs the rows of a node, the motion and the
11//! interaction pair the two rows of an edge and, inside them, the configurations with that
12//! edge's spin up and down, like a one-qubit gate in a state-vector simulator. The CPU version
13//! runs these sweeps in parallel; [`gpu`] runs them on the GPU, checked against the CPU.
14//!
15//! ```
16//! use caroli_walk::{PLUS, SpinWalk};
17//!
18//! // Ring of 6 nodes, coin angle π/8, coupling 0.2, spins along +x, walker on node 0.
19//! let walk = SpinWalk::ring(6, std::f64::consts::PI / 8.0, 0.2);
20//! let mut psi = walk.product_state(&walk.localized(0, 0), &[PLUS; 6]);
21//! walk.steps(&mut psi, 100);
22//! let total: f64 = walk.node_probabilities(&psi).iter().sum();
23//! assert!((total - 1.0).abs() < 1e-12);
24//! ```
25
26pub mod gpu;
27pub mod graph;
28pub mod observables;
29pub mod scan;
30pub mod walk;
31
32pub use caroli_gpu::Precision;
33pub use gpu::{Device, Options, Report, evolve};
34pub use graph::Graph;
35pub use scan::{ScanOptions, ScanReport, scan};
36pub use walk::{PLUS, Real, SpinWalk, UP, fourier, grover, rotation, to_double, to_single};