Python Tensor Toolbox
Project description
Copyright 2025 National Technology & Engineering Solutions of Sandia,
LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
U.S. Government retains certain rights in this software.
pyttb: Python Tensor Toolbox
Welcome to pyttb, a refactor of the
Tensor Toolbox for MATLAB in Python.
This package contains data classes and methods for manipulating dense, sparse, and structured tensors, along with algorithms for computing low-rank tensor decompositions:
- Data Classes:
tensor,sptensor,ktensor,ttensor,tenmat,sptenmat,sumtensor - Algorithms:
cp_als,cp_apr,gcp_opt,hosvd,tucker_als
Quick Start
Installation
python3 -m pip install pyttb
Example
>>> import pyttb as ttb
>>> X = ttb.tenrand((2,2,2))
>>> type(X)
<class 'pyttb.tensor.tensor'>
>>> M = ttb.cp_als(X, rank=1)
CP_ALS:
Iter 0: f = 7.367245e-01 f-delta = 7.4e-01
Iter 1: f = 7.503069e-01 f-delta = 1.4e-02
Iter 2: f = 7.508240e-01 f-delta = 5.2e-04
Iter 3: f = 7.508253e-01 f-delta = 1.3e-06
Final f = 7.508253e-01
Memory layout
For historical reasons we use Fortran memory layouts, where numpy by default uses C. This is relevant for indexing. In the future we hope to extend support for both.
>>> import numpy as np
>>> c_order = np.arange(8).reshape((2,2,2))
>>> f_order = np.arange(8).reshape((2,2,2), order="F")
>>> print(c_order[0,1,1])
3
>>> print(f_order[0,1,1])
6
Getting Help
- Documentation
- Tutorials
- Info for users coming from MATLAB
- Learn about tensor decompositions: tensor paper, tensor book
Contributing
Citing pyttb in your work
If you use pyttb in your work, please cite it using the citation info here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyttb-1.8.4.tar.gz.
File metadata
- Download URL: pyttb-1.8.4.tar.gz
- Upload date:
- Size: 186.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
189fe72aa9ab27dde1169896d5d1880316cd31435b36adf7b2638ecd911f3370
|
|
| MD5 |
16872d5d821f90e394812021c7f81b72
|
|
| BLAKE2b-256 |
65072f23cd523c36f0408c3fd6bed53bf39bcdb6aa091f8526714f3e6a905cab
|
Provenance
The following attestation bundles were made for pyttb-1.8.4.tar.gz:
Publisher:
python-publish.yml on sandialabs/pyttb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyttb-1.8.4.tar.gz -
Subject digest:
189fe72aa9ab27dde1169896d5d1880316cd31435b36adf7b2638ecd911f3370 - Sigstore transparency entry: 796198601
- Sigstore integration time:
-
Permalink:
sandialabs/pyttb@5f1e963bdb1bebcd20d9d5cf81cdafb3f2341c0e -
Branch / Tag:
refs/tags/v1.8.4 - Owner: https://github.com/sandialabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5f1e963bdb1bebcd20d9d5cf81cdafb3f2341c0e -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyttb-1.8.4-py3-none-any.whl.
File metadata
- Download URL: pyttb-1.8.4-py3-none-any.whl
- Upload date:
- Size: 151.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5995546bde6ac8c5f3356ad18a176d2e4c3a2183a51577d3d20a2aeb19a2aa88
|
|
| MD5 |
324107b6da32d1d54391a02afeff3ac8
|
|
| BLAKE2b-256 |
471181fc6b8c3b0b8941bb5ff2dd66bf86f94a33f397acb8b1eacd15e5233b04
|
Provenance
The following attestation bundles were made for pyttb-1.8.4-py3-none-any.whl:
Publisher:
python-publish.yml on sandialabs/pyttb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyttb-1.8.4-py3-none-any.whl -
Subject digest:
5995546bde6ac8c5f3356ad18a176d2e4c3a2183a51577d3d20a2aeb19a2aa88 - Sigstore transparency entry: 796198654
- Sigstore integration time:
-
Permalink:
sandialabs/pyttb@5f1e963bdb1bebcd20d9d5cf81cdafb3f2341c0e -
Branch / Tag:
refs/tags/v1.8.4 - Owner: https://github.com/sandialabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5f1e963bdb1bebcd20d9d5cf81cdafb3f2341c0e -
Trigger Event:
release
-
Statement type: