1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Einsum operations trait.
use crateResult;
use crateRuntime;
use crateTensor;
/// Einstein summation convention operations.
///
/// Einsum provides a concise way to express many common multi-dimensional
/// linear algebraic array operations using a notation inspired by Einstein summation.
///
/// # Notation
///
/// The notation string has the form `"subscripts_input1,subscripts_input2,...->subscripts_output"`.
/// Each subscript is a single lowercase letter representing a dimension.
///
/// - Repeated subscripts across inputs indicate contraction (summation) over that dimension
/// - The output subscripts specify which dimensions appear in the result
/// - If `->` is omitted, the output is the sorted list of subscripts appearing exactly once
///
/// # Examples
///
/// ```ignore
/// // Matrix multiplication: C_ik = sum_j A_ij * B_jk
/// let c = client.einsum("ij,jk->ik", &[&a, &b])?;
///
/// // Batch matrix multiplication
/// let c = client.einsum("bij,bjk->bik", &[&a, &b])?;
///
/// // Trace of a matrix
/// let trace = client.einsum("ii->", &[&a])?;
///
/// // Outer product
/// let outer = client.einsum("i,j->ij", &[&a, &b])?;
///
/// // Element-wise multiplication (Hadamard product)
/// let hadamard = client.einsum("ij,ij->ij", &[&a, &b])?;
///
/// // Sum all elements
/// let total = client.einsum("ij->", &[&a])?;
///
/// // Transpose
/// let at = client.einsum("ij->ji", &[&a])?;
/// ```