pub struct TensorIndex { /* private fields */ }Expand description
Represents an index of a tensor.
Indices in this format are associated with a direction, and as a result,
an expected output or expected generation (input) shape and ordering.
For example, a [super::network::QuditTensorNetwork] will store its output
indices in this format because after evaluation, there will
be an expected shape and ordering. The shape is determined by all the
indices directions and sizes, and the ordering will be determined by the ids.
§See Also
[super::tensor::QuditTensor]- Tensor object capturing how tensors are generated.[super::network::QuditTensorNetwork]- Tensor network describing a desired calculation.
Implementations§
Source§impl TensorIndex
impl TensorIndex
Sourcepub fn new(
direction: IndexDirection,
index_id: IndexId,
index_size: IndexSize,
) -> Self
pub fn new( direction: IndexDirection, index_id: IndexId, index_size: IndexSize, ) -> Self
Creates a new TensorIndex instance.
§Arguments
direction- The direction of the tensor leg.index_id- A unique identifier for the index.index_size- The dimension or size of the index.
§Returns
A new TensorIndex instance with the specified properties.
§Examples
use qudit_expr::index::{IndexDirection, TensorIndex};
let idx = TensorIndex::new(IndexDirection::Input, 0, 2);
assert_eq!(idx.index_id(), 0);
assert_eq!(idx.index_size(), 2);
assert_eq!(idx.direction(), IndexDirection::Input);Sourcepub fn direction(&self) -> IndexDirection
pub fn direction(&self) -> IndexDirection
Returns the IndexDirection of the tensor leg.
§Examples
use qudit_expr::index::{IndexDirection, TensorIndex};
let leg = TensorIndex::new(IndexDirection::Output, 1, 3);
assert_eq!(leg.direction(), IndexDirection::Output);Sourcepub fn index_id(&self) -> IndexId
pub fn index_id(&self) -> IndexId
Returns the IndexId of the index associated with this leg.
§Examples
use qudit_expr::index::{IndexDirection, TensorIndex};
let leg = TensorIndex::new(IndexDirection::Batch, 2, 4);
assert_eq!(leg.index_id(), 2);Sourcepub fn index_size(&self) -> IndexSize
pub fn index_size(&self) -> IndexSize
Returns the IndexSize of the index associated with this leg.
§Examples
use qudit_expr::index::{IndexDirection, TensorIndex};
let leg = TensorIndex::new(IndexDirection::Input, 3, 5);
assert_eq!(leg.index_size(), 5);Trait Implementations§
Source§impl Clone for TensorIndex
impl Clone for TensorIndex
Source§fn clone(&self) -> TensorIndex
fn clone(&self) -> TensorIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TensorIndex
impl Debug for TensorIndex
Source§impl Display for TensorIndex
impl Display for TensorIndex
Source§impl Hash for TensorIndex
impl Hash for TensorIndex
Source§impl Ord for TensorIndex
impl Ord for TensorIndex
Source§fn cmp(&self, other: &TensorIndex) -> Ordering
fn cmp(&self, other: &TensorIndex) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for TensorIndex
impl PartialEq for TensorIndex
Source§impl PartialOrd for TensorIndex
impl PartialOrd for TensorIndex
impl Copy for TensorIndex
impl Eq for TensorIndex
impl StructuralPartialEq for TensorIndex
Auto Trait Implementations§
impl Freeze for TensorIndex
impl RefUnwindSafe for TensorIndex
impl Send for TensorIndex
impl Sync for TensorIndex
impl Unpin for TensorIndex
impl UnwindSafe for TensorIndex
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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