Input Language
Variables
Variable names are alphanumeric symbols that begin with a letter. If the symbol does not correspond to any known keyword (such as a function name), it is automatically assumed to be a variable. The order of variables is inferred automatically wherever possible, defaulting to 2.
Einsum
The einsum notation expresses tensor aggregations using index strings. We use the symbol # to denote the beginning of an einsum expression, and the overall pattern is:
The table below shows how to convert common operations from linear algebra into einsum notation. Note, however, that einsum allows more than two operands as well as operands with more than two indices.
| Operation | Linear algebra | Einsum |
|---|---|---|
| Elementwise product | ||
| Inner product | ||
| Outer product | ||
| Matrix transpose | ||
| Matrix diagonal | diag | |
| Diagonal matrix | diag | |
| Matrix product |
Apart from the availability of duplicate indices in the result index string, our use of einsum is equivalent to that of existing frameworks. See numpy.einsum for more information.
Elementwise functions
The following unary and binary functions are applied elementwise to the operand tensor(s):
, , , , , (or ), , , , , , , , ,
Non-elementwise functions
The following non-elementwise functions from linear algebra are also available:
, ,
Shorthands
The following shorthands are internally mapped back to other functions.
is the sum of all elements in , e.g. for a matrix. - Similarly,
sums over the diagonal of . computes the elementwise product of and , e.g. for matrices. Scalars are also allowed.
Properties
Using the table, input tensors can restricted with a bounding interval. Even-ordered tensors may also be tagged with specific tensor properties. We generalize these properties from the matrix case as follows.
Diagonality
The diagonal of a tensor
Symmetry
Definiteness
Negative semidefiniteness and both types of strict definiteness are defined analogously.