pub enum IndexDirection {
Derivative,
Batch,
Output,
Input,
}Expand description
IndexDirection represents a tensor’s leg direction from the quantum circuit perspective.
In the context of quantum circuits and tensor networks, indices (or “legs”) of a tensor are categorized by their direction to signify their role in an operation.
While tensors may conceptually have multiple indices (legs), in the qudit-expr library,
TensorExpression objects are always generated as 1-D, 2-D, or 3-D tensors. This enum
links the conceptual/graphical tensor indices to the generated expression’s dimensions by grouping
them along directions. So all Input, Output, and Batch legs correspond to a
specific dimension of the generated tensor. This tensor network library can
use this to predict and manipulate the shape of a generated tensor.
For example, kets capture quantum states, and are represented conceptually
by column vectors. In the tensor network perspective, they are represented by
a tensor with only Output indices. They have as many indices as there are
qudits in the state and the size of each index is the radix of the qudit.
For qubits, the radix is 2, so all indices would have dimension 2. However,
when generated in the qudit-expr library, they are generated as a vector.
The IndexDirection is what is used by the qudit-tensor library to expect
a vector shape, since a ket tensor will only have indices in one direction.
Similarly, gates which capture quantum operations, are represented by unitary
matrices. As a tensor, they have indices that point in both Input and Output
directions. Even though there will likely be more than 2 indices, the qudit-tensor
library expects a matrix to be generated by the underlying TensorExpression
because of the two distinct directions.
Batch indices are used for measurements/Kraus operators or for batch executions of a network.
Variants§
Derivative
For gradients and hessians
Batch
Batch index of a tensor. These are typically represented in quantum circuits through interactions with classical systems through measurements and/or feed-forward operations. Additionally, they can capture batch computations of a network.
Output
Output leg of a tensor, corresponds to rows of an operation. In circuit diagrams, these represent the wires leaving a gate or ket.
Input
Input leg of a tensor, corresponds to columns of an operation. In circuit diagrams, these represent the wires going into a gate or bra.
Implementations§
Trait Implementations§
Source§impl Clone for IndexDirection
impl Clone for IndexDirection
Source§fn clone(&self) -> IndexDirection
fn clone(&self) -> IndexDirection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IndexDirection
impl Debug for IndexDirection
Source§impl Display for IndexDirection
impl Display for IndexDirection
Source§impl Hash for IndexDirection
impl Hash for IndexDirection
Source§impl Ord for IndexDirection
impl Ord for IndexDirection
Source§fn cmp(&self, other: &IndexDirection) -> Ordering
fn cmp(&self, other: &IndexDirection) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for IndexDirection
impl PartialEq for IndexDirection
Source§impl PartialOrd for IndexDirection
impl PartialOrd for IndexDirection
impl Copy for IndexDirection
impl Eq for IndexDirection
impl StructuralPartialEq for IndexDirection
Auto Trait Implementations§
impl Freeze for IndexDirection
impl RefUnwindSafe for IndexDirection
impl Send for IndexDirection
impl Sync for IndexDirection
impl Unpin for IndexDirection
impl UnwindSafe for IndexDirection
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<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
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>
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 more