pub struct Contraction {
pub operand_indices: Vec<Vec<char>>,
pub output_indices: Vec<char>,
pub summation_indices: Vec<char>,
}Expand description
A Contraction contains the result of parsing an einsum-formatted string.
let contraction = Contraction::new("ij,jk->ik").unwrap();
assert_eq!(contraction.operand_indices, vec![vec!['i', 'j'], vec!['j', 'k']]);
assert_eq!(contraction.output_indices, vec!['i', 'k']);
assert_eq!(contraction.summation_indices, vec!['j']);
let contraction = Contraction::new("ij,jk").unwrap();
assert_eq!(contraction.operand_indices, vec![vec!['i', 'j'], vec!['j', 'k']]);
assert_eq!(contraction.output_indices, vec!['i', 'k']);
assert_eq!(contraction.summation_indices, vec!['j']);Fields§
§operand_indices: Vec<Vec<char>>A vector with as many elements as input operands, where each
member of the vector is a Vec<char> with each char representing the label for
each axis of the operand.
output_indices: Vec<char>Specifies which axes the resulting tensor will contain
summation_indices: Vec<char>Contains the axes that will be summed over (a.k.a contracted) by the operation.
Implementations§
Source§impl Contraction
impl Contraction
Sourcepub fn new(input_string: &str) -> Result<Self, &'static str>
pub fn new(input_string: &str) -> Result<Self, &'static str>
Validates and creates a Contraction from an einsum-formatted string.
Sourcefn from_parse(parse: &EinsumParse) -> Result<Self, &'static str>
fn from_parse(parse: &EinsumParse) -> Result<Self, &'static str>
If output_indices has been specified in the parse (i.e. explicit case),
e.g. “ij,jk->ik”, simply converts the strings to Vec<char>s and passes
them to Contraction::from_indices. If the output indices haven’t been specified,
e.g. “ij,jk”, figures out which ones aren’t duplicated and hence summed over,
sorts them alphabetically, and uses those as the output indices.
Trait Implementations§
Source§impl Clone for Contraction
impl Clone for Contraction
Source§fn clone(&self) -> Contraction
fn clone(&self) -> Contraction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more