tensor#
The category of matrices with the Kronecker product as monoidal product.
Summary#
A dimension is a tuple of integers greater than one seen as a type. |
|
A tensor is a |
|
A tensor functor is a frobenius functor with a domain category |
|
A tensor diagram is a frobenius diagram with tensor boxes. |
|
alias of |
|
A tensor box is a frobenius box with an array as data. |
|
A tensor swap is a frobenius swap in a tensor diagram. |
|
A tensor cup is a frobenius cup in a tensor diagram. |
|
A tensor cap is a frobenius cap in a tensor diagram. |
|
A tensor spider is a frobenius spider in a tensor diagram. |
|
A formal sum of tensor diagrams with the same domain and codomain. |
|
Bubble in a tensor diagram, applies a function elementwise. |
Tensor combinatorial maps#
A CMap is a tensor network stored as a combinatorial map, whose
boxes are tensors, edges are summed indices and boundary ports are free
indices. Swaps, cups and caps become wiring while spiders stay as boxes.
>>> vector = Box('vector', Dim(1), Dim(2), [0, 1])
>>> assert (vector >> vector[::-1]).to_map().eval().array == 1
>>> with backend('jax'):
... import jax, jax.numpy as jnp
... b = lambda x: Box[float]('v', Dim(1), Dim(2), x * jnp.ones(2))
... f = lambda x: (b(x) >> b(x)[::-1]).to_map().eval().array
... assert jax.grad(f)(1.) == 4.