{"id":48450153,"url":"https://github.com/pierre-24/arma-einsum","last_synced_at":"2026-04-06T20:01:00.763Z","repository":{"id":349152454,"uuid":"1200696262","full_name":"pierre-24/arma-einsum","owner":"pierre-24","description":"An implementation of einsum() compatible with Armadillo","archived":false,"fork":false,"pushed_at":"2026-04-04T14:36:20.000Z","size":36,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-04-04T14:42:00.051Z","etag":null,"topics":["armadillo","armadillo-library","cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pierre-24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-03T18:10:01.000Z","updated_at":"2026-04-03T20:16:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pierre-24/arma-einsum","commit_stats":null,"previous_names":["pierre-24/arma-einsum"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pierre-24/arma-einsum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierre-24%2Farma-einsum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierre-24%2Farma-einsum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierre-24%2Farma-einsum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierre-24%2Farma-einsum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pierre-24","download_url":"https://codeload.github.com/pierre-24/arma-einsum/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierre-24%2Farma-einsum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31487542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"ssl_error","status_checked_at":"2026-04-06T17:22:54.741Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["armadillo","armadillo-library","cpp"],"created_at":"2026-04-06T20:00:48.631Z","updated_at":"2026-04-06T20:01:00.751Z","avatar_url":"https://github.com/pierre-24.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `arma-einsum`\n\nA lightweight (and [limited](#notes--limitations)) implementation of NumPy’s [`einsum()`](https://numpy.org/doc/stable/reference/generated/numpy.einsum.html) for C++, built on top of Armadillo.\n\nIt enables expressive tensor-style operations (dot products, traces, contractions, etc.) using a compact Einstein summation notation.\n\n## Notes \u0026 Limitations\n\n- Requires C++20 \n- Requires support of [`std::format`](https://github.com/paulkazusek/std_format_cheatsheet/blob/main/README.md#requirement) (i.e., GCC \u003e= 13.1 or clang \u003e= 14). It is however possible to use another equivalent library (see below).\n- Supports OMP.\n- Due to the use of Armadillo, only supports outputs up to **rank-2 (matrices)**.\n- No support for:\n    - Ellipsis (`...`)\n    - Broadcasting (NumPy-style)\n- Can partially optimize the execution path using a \"greedy\" algorithm.\n\n## Installation\n\nJust copy [`arma_einsum.hpp`](arma_einsum.hpp) into your project and make sure Armadillo is properly set up, with OpenMP enabled.\n\n```cpp\n#define ARMA_USE_OPENMP\n#include \u003carmadillo\u003e\n\n#include \"arma_einsum.hpp\"\n```\n\nThat’s it: no build system changes or additional dependencies required.\n\nIf you want to use older compilers where `std::format` is not available, you can switch to a library with an equivalent function, e.g.,  [`fmt`](https://github.com/fmtlib/fmt) (Boost's [`format`](https://www.boost.org/doc/libs/latest/libs/format/doc/format.html) should also work).\nFor example, for `fmt`, [install it](https://fmt.dev/12.0/get-started/) and use\n\n```cpp\n#include \u003cfmt/format.h\u003e\n#define ARMA_EINSUM_FORMAT fmt::format\n```\n\nbefore including `arma_einsum.hpp`.\nSee [this example](./example-meson/main_fmt.cpp).\n\nIf you want to use a Meson wrap file instead, check [the example](example-meson).\n\n## Usage\n\n```cpp\narmaeinsum::einsum_mat\u003cT\u003e(\"equation\", operand1, operand2, ...);\narmaeinsum::einsum_mat_opt\u003cT\u003e(level, \"equation\", operand1, operand2, ...);\n```\n\nThe latter will be faster, but might generate intermediate results.\n\n### Parameters\n\n- **`T`**: Any floating point type supported by Armadillo (mixing types is not supported).\n- **`level`**: level of optimization for the path, for the moment only `armaeinsum::Greedy` is available.\n- **`equation`**: A string describing the Einstein summation (see below).\n- **`operands`**: A variadic list of Armadillo objects:\n    - `arma::Col`\n    - `arma::Row`\n    - `arma::Mat`\n    - `arma::Cube`\n\n### Equation Format\n\nThe equation string follows standard Einstein summation notation:\n\n```\n\"indices[,indices...][-\u003eoutput_indices]\"\n```\n\n### Rules\n\n- Input operands are separated by commas:\n  ```\n  \"ij,jk\"\n  ```\n- Repeated indices are **summed over** (contraction).\n- Non-repeated indices define the output dimensions (in order of appearance).\n- You can explicitly define the output using `-\u003e`:\n  ```\n  \"ij,jk-\u003eik\"\n  ```\n- If `-\u003e` is omitted, output indices are inferred automatically, in alphabetical order (thus `\"ji\"` is `\"ji-\u003eij\"\"`).\n- **The output must be representable as a `arma::Mat\u003cT\u003e`**.\n\n## Examples\n\nAssume:\n\n- `a`, `b` are vectors (`arma::Col` or `arma::Row`)\n- `A`, `B` are matrices (`arma::Mat`)\n\n| Expression            | Description                   |\n|-----------------------|-------------------------------|\n| `(\"i,i\", a, b)`       | Dot product                   |\n| `(\"i,j-\u003eij\", a, b)`   | Outer product                 |\n| `(\"ii\", A)`           | Trace                         |\n| `(\"ij-\u003eji\", A)`       | Transpose                     |\n| `(\"ij-\u003e\", A)`         | Sum of all elements           |\n| `(\"ij,j\", A, a)`      | Matrix-vector multiplication  |\n| `(\"ik,kj\", A, B)`     | Matrix-matrix multiplication  |\n\n\n## Development\n\n[Issues](https://github.com/pierre-24/arma-einsum/issues) and [pull requests](https://github.com/pierre-24/arma-einsum/pull/) are welcomed :)\n\nTo help, you can start by [forking the repository](https://github.com/pierre-24/arma-einsum/fork), and then\n\n```bash\ngit clone git@github.com:YOUR_USERNAME/arma-einsum.git\ncd arma-einsum\n```\n\nIt is recommended to use the [Meson](https://mesonbuild.com/) build system:\n\n```bash\n# setup\nmeson setup _build\n\n# compile\nmeson compile -C _build\n\n# run test suites\nOMP_NUM_THREADS=4 meson test -C _build\n\n# run benchmark\nOMP_NUM_THREADS=4 meson test --benchmark --verbose -C _build\n```\n\nYou can also check linting via [`cpplint`](https://github.com/cpplint/cpplint) using:\n\n```bash\npip install cpplint  # optional: use virtualenv\n\nmake lint\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierre-24%2Farma-einsum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierre-24%2Farma-einsum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierre-24%2Farma-einsum/lists"}