pub struct TensorExpression { /* private fields */ }Implementations§
Source§impl TensorExpression
impl TensorExpression
pub fn new<T: AsRef<str>>(input: T) -> Self
pub fn from_raw(indices: Vec<TensorIndex>, inner: NamedExpression) -> Self
pub fn indices(&self) -> &[TensorIndex]
pub fn dimensions(&self) -> Vec<IndexSize> ⓘ
pub fn rank(&self) -> usize
pub fn generation_shape(&self) -> GenerationShape
Sourcepub fn tensor_strides(&self) -> Vec<usize>
pub fn tensor_strides(&self) -> Vec<usize>
Calculates the strides for each dimension of the tensor.
The stride for a dimension is the number of elements one must skip in the flattened array to move to the next element along that dimension. The strides are calculated such that the last dimension has a stride of 1, the second to last dimension has a stride equal to the size of the last dimension, and so on.
§Examples
use qudit_expr::TensorExpression;
let mut tensor = TensorExpression::new("example() {[
[
[ 1, 0, 0, 0 ],
[ 0, 1, 0, 0 ],
[ 0, 0, 1, 0 ],
[ 0, 0, 0, 1 ],
], [
[ 1, 0, 0, 0 ],
[ 0, 1, 0, 0 ],
[ 0, 0, 0, 1 ],
[ 0, 0, 1, 0 ],
]
]}");
assert_eq!(tensor.tensor_strides(), vec![16, 8, 4, 2, 1]);pub fn reindex(&mut self, new_indices: Vec<TensorIndex>) -> &mut Self
pub fn permute( &mut self, perm: &[usize], redirection: Vec<IndexDirection>, ) -> &mut Self
pub fn stack_with_identity( &self, positions: &[usize], new_dim: usize, ) -> TensorExpression
pub fn partial_trace( &self, dimension_pairs: &[(usize, usize)], ) -> TensorExpression
Sourcepub fn substitute_parameters<S: AsRef<str>, C: AsRef<Expression>>(
&self,
variables: &[S],
values: &[C],
) -> Self
pub fn substitute_parameters<S: AsRef<str>, C: AsRef<Expression>>( &self, variables: &[S], values: &[C], ) -> Self
replace all variables with values, new variables given in variables input
pub fn destruct( self, ) -> (String, Vec<String>, Vec<ComplexExpression>, Vec<TensorIndex>)
Methods from Deref<Target = NamedExpression>§
Trait Implementations§
Source§impl AsRef<NamedExpression> for TensorExpression
impl AsRef<NamedExpression> for TensorExpression
Source§fn as_ref(&self) -> &NamedExpression
fn as_ref(&self) -> &NamedExpression
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Clone for TensorExpression
impl Clone for TensorExpression
Source§fn clone(&self) -> TensorExpression
fn clone(&self) -> TensorExpression
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 TensorExpression
impl Debug for TensorExpression
Source§impl Deref for TensorExpression
impl Deref for TensorExpression
Source§impl DerefMut for TensorExpression
impl DerefMut for TensorExpression
Source§impl From<BraExpression> for TensorExpression
impl From<BraExpression> for TensorExpression
Source§fn from(value: BraExpression) -> Self
fn from(value: BraExpression) -> Self
Converts to this type from the input type.
Source§impl From<BraSystemExpression> for TensorExpression
impl From<BraSystemExpression> for TensorExpression
Source§fn from(value: BraSystemExpression) -> Self
fn from(value: BraSystemExpression) -> Self
Converts to this type from the input type.
Source§impl From<IsometryExpression> for TensorExpression
impl From<IsometryExpression> for TensorExpression
Source§fn from(value: IsometryExpression) -> Self
fn from(value: IsometryExpression) -> Self
Converts to this type from the input type.
Source§impl From<KetExpression> for TensorExpression
impl From<KetExpression> for TensorExpression
Source§fn from(value: KetExpression) -> Self
fn from(value: KetExpression) -> Self
Converts to this type from the input type.
Source§impl From<KetSystemExpression> for TensorExpression
impl From<KetSystemExpression> for TensorExpression
Source§fn from(value: KetSystemExpression) -> Self
fn from(value: KetSystemExpression) -> Self
Converts to this type from the input type.
Source§impl From<KrausOperatorsExpression> for TensorExpression
impl From<KrausOperatorsExpression> for TensorExpression
Source§fn from(value: KrausOperatorsExpression) -> Self
fn from(value: KrausOperatorsExpression) -> Self
Converts to this type from the input type.
Source§impl From<TensorExpression> for NamedExpression
impl From<TensorExpression> for NamedExpression
Source§fn from(value: TensorExpression) -> Self
fn from(value: TensorExpression) -> Self
Converts to this type from the input type.
Source§impl From<UnitaryExpression> for TensorExpression
impl From<UnitaryExpression> for TensorExpression
Source§fn from(value: UnitaryExpression) -> Self
fn from(value: UnitaryExpression) -> Self
Converts to this type from the input type.
Source§impl From<UnitarySystemExpression> for TensorExpression
impl From<UnitarySystemExpression> for TensorExpression
Source§fn from(value: UnitarySystemExpression) -> Self
fn from(value: UnitarySystemExpression) -> Self
Converts to this type from the input type.
Source§impl PartialEq for TensorExpression
impl PartialEq for TensorExpression
Source§impl TryFrom<TensorExpression> for BraExpression
impl TryFrom<TensorExpression> for BraExpression
Source§impl TryFrom<TensorExpression> for IsometryExpression
impl TryFrom<TensorExpression> for IsometryExpression
Source§impl TryFrom<TensorExpression> for KetExpression
impl TryFrom<TensorExpression> for KetExpression
Source§impl TryFrom<TensorExpression> for UnitaryExpression
impl TryFrom<TensorExpression> for UnitaryExpression
impl Eq for TensorExpression
impl StructuralPartialEq for TensorExpression
Auto Trait Implementations§
impl Freeze for TensorExpression
impl RefUnwindSafe for TensorExpression
impl Send for TensorExpression
impl Sync for TensorExpression
impl Unpin for TensorExpression
impl UnwindSafe for TensorExpression
Blanket Implementations§
Source§impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
fn as_generalized_ref(&'short self) -> &'short Target
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> 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