pub struct Tensor {
pub id: usize,
pub data: ArrayD<Complex<f64>>,
pub indices: Vec<String>,
pub shape: Vec<usize>,
}
Expand description
A tensor in the network
Fields§
§id: usize
Unique identifier for the tensor
data: ArrayD<Complex<f64>>
The tensor data
indices: Vec<String>
Labels for each index of the tensor
shape: Vec<usize>
Shape of the tensor
Implementations§
Source§impl Tensor
impl Tensor
Sourcepub fn new(id: usize, data: ArrayD<Complex<f64>>, indices: Vec<String>) -> Self
pub fn new(id: usize, data: ArrayD<Complex<f64>>, indices: Vec<String>) -> Self
Create a new tensor
Sourcepub fn from_matrix(
id: usize,
matrix: Array2<Complex<f64>>,
in_idx: String,
out_idx: String,
) -> Self
pub fn from_matrix( id: usize, matrix: Array2<Complex<f64>>, in_idx: String, out_idx: String, ) -> Self
Create a tensor from a 2D array (matrix)
Sourcepub fn qubit_zero(id: usize, idx: String) -> Self
pub fn qubit_zero(id: usize, idx: String) -> Self
Create a qubit tensor in |0⟩ state
Sourcepub fn from_array<D>(
array: ArrayBase<OwnedRepr<Complex<f64>>, D>,
indices: Vec<usize>,
) -> Selfwhere
D: Dimension,
pub fn from_array<D>(
array: ArrayBase<OwnedRepr<Complex<f64>>, D>,
indices: Vec<usize>,
) -> Selfwhere
D: Dimension,
Create a tensor from an ndarray with specified indices
Sourcepub fn contract(
&self,
other: &Tensor,
self_idx: &str,
other_idx: &str,
) -> QuantRS2Result<Tensor>
pub fn contract( &self, other: &Tensor, self_idx: &str, other_idx: &str, ) -> QuantRS2Result<Tensor>
Contract this tensor with another over specified indices
Sourcepub fn svd_decompose(
&self,
idx: usize,
max_rank: Option<usize>,
) -> QuantRS2Result<(Tensor, Tensor)>
pub fn svd_decompose( &self, idx: usize, max_rank: Option<usize>, ) -> QuantRS2Result<(Tensor, Tensor)>
Apply SVD decomposition to split tensor along specified index
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnwindSafe for Tensor
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
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>
Converts
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>
Converts
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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.