pub struct TensorNetwork {
pub tensors: HashMap<usize, Tensor>,
pub connections: Vec<(TensorIndex, TensorIndex)>,
pub num_qubits: usize,
pub max_bond_dimension: usize,
pub detected_circuit_type: CircuitType,
pub using_qft_optimization: bool,
pub using_qaoa_optimization: bool,
pub using_linear_optimization: bool,
pub using_star_optimization: bool,
/* private fields */
}
Expand description
Tensor network representation of a quantum circuit
Fields§
§tensors: HashMap<usize, Tensor>
Collection of tensors in the network
connections: Vec<(TensorIndex, TensorIndex)>
Connections between tensor indices
num_qubits: usize
Number of physical qubits
max_bond_dimension: usize
Maximum bond dimension for approximations
detected_circuit_type: CircuitType
Detected circuit type for optimization
using_qft_optimization: bool
Whether QFT optimization is enabled
using_qaoa_optimization: bool
Whether QAOA optimization is enabled
using_linear_optimization: bool
Whether linear optimization is enabled
using_star_optimization: bool
Whether star optimization is enabled
Implementations§
Source§impl TensorNetwork
impl TensorNetwork
Sourcepub fn add_tensor(&mut self, tensor: Tensor) -> usize
pub fn add_tensor(&mut self, tensor: Tensor) -> usize
Add a tensor to the network
Sourcepub fn connect(&mut self, idx1: TensorIndex, idx2: TensorIndex) -> Result<()>
pub fn connect(&mut self, idx1: TensorIndex, idx2: TensorIndex) -> Result<()>
Connect two tensor indices
Sourcepub fn get_neighbors(&self, tensor_id: usize) -> Vec<usize>
pub fn get_neighbors(&self, tensor_id: usize) -> Vec<usize>
Get all tensors connected to the given tensor
Sourcepub fn contract_all(&self) -> Result<Complex64>
pub fn contract_all(&self) -> Result<Complex64>
Contract all tensors to compute the final amplitude
Sourcepub fn total_elements(&self) -> usize
pub fn total_elements(&self) -> usize
Get the total number of elements across all tensors
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Estimate memory usage in bytes
Sourcepub fn find_optimal_contraction_order(&self) -> Result<Vec<usize>>
pub fn find_optimal_contraction_order(&self) -> Result<Vec<usize>>
Find optimal contraction order using dynamic programming
Sourcepub fn find_lowest_cost_pair(
&self,
tensors: &[Tensor],
) -> Result<(usize, usize, f64)>
pub fn find_lowest_cost_pair( &self, tensors: &[Tensor], ) -> Result<(usize, usize, f64)>
Find the pair of tensors with lowest contraction cost
Sourcepub fn estimate_contraction_cost(
&self,
tensor_a: &Tensor,
tensor_b: &Tensor,
) -> f64
pub fn estimate_contraction_cost( &self, tensor_a: &Tensor, tensor_b: &Tensor, ) -> f64
Estimate the computational cost of contracting two tensors
Sourcepub fn contract_tensor_pair(
&self,
tensor_a: &Tensor,
tensor_b: &Tensor,
) -> Result<Tensor>
pub fn contract_tensor_pair( &self, tensor_a: &Tensor, tensor_b: &Tensor, ) -> Result<Tensor>
Contract two tensors optimally
Sourcepub fn set_basis_state_boundary(&mut self, basis_state: usize) -> Result<()>
pub fn set_basis_state_boundary(&mut self, basis_state: usize) -> Result<()>
Set boundary conditions for a specific computational basis state
Trait Implementations§
Source§impl Clone for TensorNetwork
impl Clone for TensorNetwork
Source§fn clone(&self) -> TensorNetwork
fn clone(&self) -> TensorNetwork
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TensorNetwork
impl Debug for TensorNetwork
Auto Trait Implementations§
impl Freeze for TensorNetwork
impl RefUnwindSafe for TensorNetwork
impl Send for TensorNetwork
impl Sync for TensorNetwork
impl Unpin for TensorNetwork
impl UnwindSafe for TensorNetwork
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.