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.

OperationLinear algebraEinsum
Elementwise product
Inner product
Outer product
Matrix transpose
Matrix diagonaldiag
Diagonal matrixdiag
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):

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.

Assignments

For convenientce, the main expression may be preceeded by assigments of the form NAME = expression. Subsequent expressions may use NAME to reference the assigned expression. The final expression must not be part of an assignment. Separating assignments with linebreaks is recommended but not required.