pub fn phase_rotation_operator(
r: usize,
theta: f64,
) -> Result<LinearOperator<TensorDynLen, usize>>Expand description
Create a phase rotation operator: f(x) = exp(iθx) * g(x)
This MPO multiplies a function g(x) by the phase factor exp(iθx).
In quantics representation, x = Σ_n x_n * 2^(R-n), so: exp(iθx) = Π_n exp(iθ2^(R-n)*x_n)
Each site contributes an independent phase factor, making this a diagonal operator with bond dimension 1.
§Arguments
r- Number of bits (sites)theta- Phase angle in radians
§Returns
LinearOperator representing the phase rotation
§Examples
use tensor4all_quanticstransform::phase_rotation_operator;
use std::f64::consts::PI;
// Create phase rotation by π/4 for 4-bit quantics
let op = phase_rotation_operator(4, PI / 4.0).unwrap();
// The operator has one MPO tensor per bit
assert_eq!(op.mpo.node_count(), 4);
// Phase rotation is a diagonal operator (bond dimension 1)
// Error on invalid input
assert!(phase_rotation_operator(0, 1.0).is_err());
assert!(phase_rotation_operator(4, f64::NAN).is_err());
assert!(phase_rotation_operator(4, f64::INFINITY).is_err());