{"id":20393501,"url":"https://github.com/pseewald/fortran-einsum-example","last_synced_at":"2026-03-09T15:02:11.298Z","repository":{"id":114458094,"uuid":"276393048","full_name":"pseewald/fortran-einsum-example","owner":"pseewald","description":"A generic implementation of tensor einsum in Fortran.","archived":false,"fork":false,"pushed_at":"2021-01-29T20:11:11.000Z","size":95,"stargazers_count":26,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-15T10:55:27.736Z","etag":null,"topics":["einsum","fortran","generic-programming","tensor"],"latest_commit_sha":null,"homepage":"","language":"Fortran","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/pseewald.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}},"created_at":"2020-07-01T14:01:19.000Z","updated_at":"2025-01-08T04:13:32.000Z","dependencies_parsed_at":"2023-06-11T03:24:16.446Z","dependency_job_id":null,"html_url":"https://github.com/pseewald/fortran-einsum-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseewald%2Ffortran-einsum-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseewald%2Ffortran-einsum-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseewald%2Ffortran-einsum-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pseewald%2Ffortran-einsum-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pseewald","download_url":"https://codeload.github.com/pseewald/fortran-einsum-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241944808,"owners_count":20046829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["einsum","fortran","generic-programming","tensor"],"created_at":"2024-11-15T03:49:07.065Z","updated_at":"2026-03-09T15:02:11.230Z","avatar_url":"https://github.com/pseewald.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fortran-einsum-example\n\nThis project goes back to a talk I gave at the [FortranCon conference 2020](https://tcevents.chem.uzh.ch/event/12/). It demonstrates how to develop generic APIs in Fortran by making use of polymorphism and generic programming techniques. This specific example implements a tensor contraction / Einstein summation API. To learn more have a look at the [presentation slides](presentation.pdf).\n\n\n## Examples\nsum(k) A(ijk) B(kj) = C(i)\n```Fortran\nclass(tensor), allocatable :: a, b, c\n\nreal, dimension(:,:,:), allocatable :: data_a\nreal, dimension(:,:), allocatable :: data_b\n\n! ... allocate and assign data_a, data_b ...\n\na = tensor(data_a)\nb = tensor(data_b)\n\nc = tensor_einsum( \u0026\n   a, [1,2,3], b, [3,2], [1])\n```\nsum(ij) A(ijkl) B(jim) = C(mkl)\n```Fortran\nclass(tensor), allocatable :: a, b, c\n\ninteger, dimension(:,:,:,:), allocatable :: data_a\ninteger, dimension(:,:,:), allocatable :: data_b\n\n! ... allocate and assign data_a, data_b ...\n\na = tensor(data_a)\nb = tensor(data_b)\n\nc = tensor_einsum( \u0026\n   a, [1,2,3,4], b, [2,1,5], [5,3,4])\n```\n\nA working example that can be compiled and run is [included](tensor_example.f90).\n\n## Dependencies\n* [Fypp](https://github.com/aradi/fypp) preprocessor\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseewald%2Ffortran-einsum-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpseewald%2Ffortran-einsum-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseewald%2Ffortran-einsum-example/lists"}