Skip to main content

triangle_operator

Function triangle_operator 

Source
pub fn triangle_operator(
    r: usize,
    triangle: TriangleType,
) -> Result<LinearOperator<TensorDynLen, usize>>
Expand description

Create a triangular matrix operator with the specified triangle type.

  • Lower: M[i,j] = 1 when i > j (prefix sum: y_i = sum of x_j for j < i)
  • Upper: M[i,j] = 1 when i < j (suffix sum: y_i = sum of x_j for j > i)

§Arguments

  • r - Number of bits (sites). Must be at least 2.
  • triangle - Which triangle to use

§Examples

use tensor4all_quanticstransform::{triangle_operator, TriangleType};

let op = triangle_operator(4, TriangleType::Lower).unwrap();
assert_eq!(op.mpo.node_count(), 4);

// Requires at least 2 sites
assert!(triangle_operator(1, TriangleType::Lower).is_err());