{"id":20089516,"url":"https://github.com/bassoy/ttm","last_synced_at":"2025-07-16T01:33:57.999Z","repository":{"id":225840665,"uuid":"740885517","full_name":"bassoy/ttm","owner":"bassoy","description":"C++ Header-Only Library for High-Performance Tensor-Matrix Multiplication","archived":false,"fork":false,"pushed_at":"2024-09-14T18:06:15.000Z","size":159,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-15T17:56:58.117Z","etag":null,"topics":["linear-algebra","multilinear-algebra","tensor","tensor-computation","tensor-times-matrix"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bassoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-01-09T09:15:12.000Z","updated_at":"2024-04-29T09:46:55.000Z","dependencies_parsed_at":"2024-03-04T16:34:48.365Z","dependency_job_id":"e34ea0ef-8bc1-4e1d-b3a6-fdb1d3307873","html_url":"https://github.com/bassoy/ttm","commit_stats":null,"previous_names":["bassoy/ttm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bassoy/ttm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bassoy%2Fttm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bassoy%2Fttm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bassoy%2Fttm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bassoy%2Fttm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bassoy","download_url":"https://codeload.github.com/bassoy/ttm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bassoy%2Fttm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265473891,"owners_count":23772214,"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":["linear-algebra","multilinear-algebra","tensor","tensor-computation","tensor-times-matrix"],"created_at":"2024-11-13T16:18:11.480Z","updated_at":"2025-07-16T01:33:57.990Z","avatar_url":"https://github.com/bassoy.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"High-Performance Tensor-Matrix Multiplication Library - TLIB(TTM)\n=====\n[![Language](https://img.shields.io/badge/C%2B%2B-17-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)\n[![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://github.com/bassoy/ttm/blob/master/LICENSE)\n[![Wiki](https://img.shields.io/badge/ttm-wiki-blue.svg)](https://github.com/bassoy/ttm/wiki)\n[![Discussions](https://img.shields.io/badge/ttm-discussions-blue.svg)](https://github.com/bassoy/ttm/discussions)\n[![Build Status](https://github.com/bassoy/ttm/actions/workflows/test.yml/badge.svg)](https://github.com/bassoy/ttm/actions)\n\n## Summary\n**TLIB(TTM)** is C++ high-performance tensor-matrix multiplication **header-only library**.\nIt provides free C++ functions for parallel computing the **mode-`q` tensor-times-matrix product** of the general form\n\n$$\n\\underline{\\mathbf{C}} = \\underline{\\mathbf{A}} \\times_q \\mathbf{B} \\quad :\\Leftrightarrow \\quad\n\\underline{\\mathbf{C}} (i_1, \\dots, i_{q-1}, j, i_{q+1}, \\dots, i_p) = \\sum_{i_q=1}^{n_q} \\underline{\\mathbf{A}}({i_1, \\dots, i_q,  \\dots, i_p}) \\cdot \\mathbf{B}({j,i_q}).\n$$\n\nwhere $q$ is the contraction mode, $\\underline{\\mathbf{A}}$ and $\\underline{\\mathbf{C}}$ are tensors of order $p$ with shapes $\\mathbf{n}\\_a= (n\\_1,\\dots n\\_{q-1},n\\_q ,n\\_{q+1},\\dots,n\\_p)$ and $\\mathbf{n}\\_c = (n\\_1,\\dots,n\\_{q-1},m,n\\_{q+1},\\dots,n\\_p)$, respectively. The order $2$ tensor $\\mathbf{B}$ is a matrix with shape $\\mathbf{n}\\_b = (m,n\\_{q})$.\n\n## Usage \u0026 Installation\n\nPlease have a look at the [wiki](https://github.com/bassoy/ttm/wiki) page for more informations about library **usage**, function **interfaces** and the **parameters** settings.\n\n## Key Features\n\n### Flexibility\n* Contraction mode $q$, tensor order $p$, tensor extents $n$ and tensor layout $\\mathbf{\\pi}$ can be chosen at runtime\n* Supports any linear tensor layout inlcuding the first-order and last-order storage layouts\n* Offers two high-level and one C-like low-level interfaces for calling the tensor-times-matrix multiplication\n* Implemented independent of a tensor data structure (can be used with `std::vector` and `std::array`)\n* Currently supports float and double\n\n### Performance\n* Multi-threading support with OpenMP v4.5 or higher\n* Currently must be used with a BLAS implementation\n* Performs in-place operations without transposing the tensor - no extra memory needed\n* For large tensors reaches peak matrix-times-matrix performance\n\n### Requirements\n* Requires the tensor elements to be contiguously stored in memory\n* Element types must be either `float` or `double`\n\n## Python Example\n```python\nimport numpy as np\nimport ttmpy as tp\n\nA = np.arange(4*3*2, dtype=np.float64).reshape(4,3,2)\nB = np.arange(5*4,   dtype=np.float64).reshape(5,4)\nC = tp.ttm(1,A,B)\nD = np.einsum(\"ijk,xi-\u003exjk\", A, B)\nnp.all(np.equal(C,D))\n```\n\n## C++ Example \n```cpp\n/*main.cpp*/\n#include \u003ctlib/ttm.h\u003e\n\n#include \u003cvector\u003e\n#include \u003cnumeric\u003e\n#include \u003ciostream\u003e\n\n\nint main()\n{\n    using value_t    = float;\n    using tensor_t   = tlib::tensor\u003cvalue_t\u003e;\n\n    auto A = tensor_t( {4,3,2} );\n    auto B = tensor_t( {5,4}   );\n\n    std::iota(A.begin(),A.end(),1);\n    std::fill(B.begin(),B.end(),1);\n    \n    std::cout \u003c\u003c \"A = \" \u003c\u003c A \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"B = \" \u003c\u003c B \u003c\u003c std::endl;\n\n/*\n  A =\n  { 1  5  9  | 13 17 21\n    2  6 10  | 14 18 22\n    3  7 11  | 15 19 23\n    4  8 12  | 16 20 24 };\n\n  B =\n  { 1  1  1  1  1\n    1  1  1  1  1\n    1  1  1  1  1\n    1  1  1  1  1};\n*/\n\n    auto C = A (1)* B;\n\n    std::cout \u003c\u003c \"C = \" \u003c\u003c C \u003c\u003c std::endl;\n\n\n/* for q=1\n  C =\n  { 1+..+4 5+..+8 9+..+12 | 13+..+16 17+..+20 21+..+24\n      ..     ..     ..    |    ..       ..       ..\n    1+..+4 5+..+8 9+..+12 | 13+..+16 17+..+20 21+..+24 };\n*/\n}\n```\n\n\n## Citation\nIf you want to refer to TTM as part of a research paper, please cite the article [Design of a high-performance tensor–matrix multiplication with BLAS](https://doi.org/10.1016/j.jocs.2025.102568)\n\n```\n@article{ttm:bassoy:2025,\ntitle = {Design of a high-performance tensor–matrix multiplication with BLAS},\njournal = {Journal of Computational Science},\nvolume = {87},\npages = {102568},\nyear = {2025},\nissn = {1877-7503},\ndoi = {https://doi.org/10.1016/j.jocs.2025.102568},\nurl = {https://www.sciencedirect.com/science/article/pii/S1877750325000456},\nauthor = {Cem Savas Bassoy},\n}\n``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbassoy%2Fttm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbassoy%2Fttm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbassoy%2Fttm/lists"}