pub struct TensorNetwork {
pub tensors: Vec<Tensor>,
}Expand description
An unordered bag of tensors to be contracted into a scalar.
Fields§
§tensors: Vec<Tensor>Implementations§
Source§impl TensorNetwork
impl TensorNetwork
Sourcepub fn contract_all(&self) -> QuantumResult<Tensor>
pub fn contract_all(&self) -> QuantumResult<Tensor>
Greedily contract the whole network and return the resulting tensor.
The contraction order is a simple greedy heuristic: repeatedly contract the pair of tensors sharing the most legs (falling back to the first pair when none share a leg, producing an outer product). For shallow circuits this keeps intermediate ranks small.
§Errors
Returns QuantumError::EmptyInput if the network is empty.
Sourcepub fn contract_to_scalar(&self) -> QuantumResult<Complex<f32>>
pub fn contract_to_scalar(&self) -> QuantumResult<Complex<f32>>
Contract to a scalar (the full amplitude).
§Errors
Returns an error if the final tensor is not rank-0.
Trait Implementations§
Source§impl Clone for TensorNetwork
impl Clone for TensorNetwork
Source§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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more