# safe-tensor: Dependently typed tensor algebra

[ library, math, mit ] [ Propose Tags ]

#### Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.1.1 CHANGELOG.md base (>=4.7 && <5), constraints (>=0.10 && <0.14), containers (>=0.6 && <0.7), deepseq (>=1.4 && <1.5), hmatrix (>=0.20 && <0.21), mtl (>=2.2 && <2.3), singletons (>=2.5 && <2.8) [details] MIT 2020 Nils Alex Nils Alex nils.alex@fau.de Math https://github.com/nilsalex/safe-tensor#readme https://github.com/nilsalex/safe-tensor/issues head: git clone https://github.com/nilsalex/safe-tensor by nalex at 2021-02-27T17:37:40Z 734 total (8 in the last 30 days) (no votes yet) [estimated by Bayesian average] λ λ λ Docs available Last success reported on 2021-02-27

[back to package description]

# safe-tensor

Dependently typed tensor algebra in Haskell. Useful for applications in field theory, e.g., carrying out calculations for https://doi.org/10.1103/PhysRevD.101.084025

## Rationale

Tensor calculus is reflected in the type system. We regard a tensor as a multilinear map from a product of vector spaces and duals thereof to the common field. The type of each tensor is its generalized rank, describing the vector spaces it acts on and assigning a label to each vector space. There are a few rules for tensor operations:

• Only tensors of the same type may be added. The result is a tensor of this type.
• Tensors may be multiplied if the resulting generalized rank does not contain repeated labels for the same (dual) vector space.
• The contraction of a tensors removes pairs of vector space and dual vector space with the same label from the generalized rank.

It is thus impossible to perform inconsistent tensor operations.

There is also an existentially typed variant of the tensor type useful for runtime computations. These computations take place in the Error monad, throwing errors if operand types are not consistent.

The approach is described in detail in the Hackage documentation.