Skip to content
Input Language

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.

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):

  • , , ,
  • , ,
  • (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 of order is a tensor of order (not always a vector), namely . is a diagonal tensor if and only if all non-diagonal entries are .

Symmetry

is symmetric if and only if .

Definiteness

is positive semi-definite if and only if for all matching tensors of order , .

Negative semidefiniteness and both types of strict definiteness are defined analogously.