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 more