Struct Subscripts
pub struct Subscripts {
pub inputs: Vec<Vec<u32>>,
pub output: Vec<u32>,
}Expand description
Einsum subscripts using integer labels (omeinsum-rs compatible).
Each dimension is represented by a u32 label. Labels shared across
multiple input tensors are contracted (summed over). Labels present
only in the output are free indices.
§Examples
use tenferro_einsum::Subscripts;
// Matrix multiplication: C_{ik} = Σ_j A_{ij} * B_{jk}
let subs = Subscripts::new(&[&[0, 1], &[1, 2]], &[0, 2]);
assert_eq!(subs.inputs.len(), 2);
assert_eq!(subs.output, vec![0, 2]);use tenferro_einsum::Subscripts;
// Parse from string notation
let subs = Subscripts::parse("ij,jk->ik").unwrap();
assert_eq!(subs.inputs.len(), 2);Fields§
§inputs: Vec<Vec<u32>>Index labels for each input tensor.
output: Vec<u32>Index labels for the output tensor.
Implementations§
§impl Subscripts
impl Subscripts
pub fn new(inputs: &[&[u32]], output: &[u32]) -> Subscripts
pub fn new(inputs: &[&[u32]], output: &[u32]) -> Subscripts
Create subscripts from integer label arrays.
§Arguments
inputs— Index labels for each input tensoroutput— Index labels for the output tensor
pub fn parse(notation: &str) -> Result<Subscripts, Error>
pub fn parse(notation: &str) -> Result<Subscripts, Error>
Parse subscripts from NumPy/PyTorch-style string notation.
Each Unicode alphanumeric character represents a dimension label.
Labels are mapped to integer IDs via Unicode scalar values (char as u32).
Input tensors are separated by commas, and -> separates inputs
from the output.
Parentheses in the notation are accepted but stripped during parsing.
To respect parenthesized contraction order, use [crate::NestedEinsum::parse]
or pass the parenthesized string directly to crate::einsum.
§Examples
"ij,jk->ik"— matrix multiplication"ii->i"— diagonal extraction"ijk->"— full contraction (scalar result)"ij,(jk,kl)->il"— contract B and C first, then with A
§Errors
Returns an error if the notation is malformed.
Trait Implementations§
§impl Clone for Subscripts
impl Clone for Subscripts
§fn clone(&self) -> Subscripts
fn clone(&self) -> Subscripts
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Subscripts
impl RefUnwindSafe for Subscripts
impl Send for Subscripts
impl Sync for Subscripts
impl Unpin for Subscripts
impl UnwindSafe for Subscripts
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,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
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