https://github.com/adtzlr/named-einsum
NumPy's Einsum, but with named subscripts.
https://github.com/adtzlr/named-einsum
einsum numpy python
Last synced: 11 months ago
JSON representation
NumPy's Einsum, but with named subscripts.
- Host: GitHub
- URL: https://github.com/adtzlr/named-einsum
- Owner: adtzlr
- License: mit
- Created: 2023-10-15T21:43:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T08:24:07.000Z (over 2 years ago)
- Last Synced: 2025-03-02T09:14:05.432Z (12 months ago)
- Topics: einsum, numpy, python
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Neinsum
A Named Einsum.
> *NumPy's Einsum, but with named subscripts.*
[](https://pypi.python.org/pypi/neinsum/) [](https://spdx.org/licenses/MIT.html) [](https://codecov.io/gh/adtzlr/named-einsum) 
# Installation
Neinsum is available on PyPI (and requires NumPy).
```
pip install neinsum
```
# Usage
With `neinsum`, it is possible to add names to the subscripts, i.e. instead of the indices-only `ij` in `np.einsum`, a named-subscript `A_ij` has to be provided. The variable names - like `A` (without indices) - are further used as keyword-arguments, see the example code-block. This is also supported for the output array.
```python
import numpy as np
from neinsum import named_einsum
x = np.eye(3)
y = np.arange(9).reshape(3, 3)
named_einsum("A_ij,B_kl")(A=x, B=y)
# this is equal to
np.einsum("ij,kl", x, y)
```