Metadata-Version: 2.1
Name: pyttb
Version: 1.8.2
Summary: Python Tensor Toolbox
Author-email: "Daniel M. Dunlavy" <dmdunla@sandia.gov>
License: BSD 2-Clause License
Project-URL: homepage, https://github.com/sandialabs/pyttb
Project-URL: coverage, https://coveralls.io/github/sandialabs/pyttb
Project-URL: documentation, https://pyttb.readthedocs.io
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy<3.0,>=1.24
Requires-Dist: numpy_groupies>0.11
Requires-Dist: scipy<1.15,>1.9
Requires-Dist: matplotlib>3.7
Provides-Extra: dev
Requires-Dist: mypy<1.14.0,>=1.10; extra == "dev"
Requires-Dist: nbstripout<0.9,>=0.8; extra == "dev"
Requires-Dist: pytest>8.0; extra == "dev"
Requires-Dist: pytest-cov>5.0; extra == "dev"
Requires-Dist: ruff<0.8,>=0.7; extra == "dev"
Requires-Dist: pre-commit<5.0,>=4.0; extra == "dev"
Provides-Extra: doc
Requires-Dist: sphinx>=4.0; extra == "doc"
Requires-Dist: sphinx_rtd_theme>2.0; extra == "doc"
Requires-Dist: myst-nb>1.0; extra == "doc"
Provides-Extra: profiling
Requires-Dist: gprof2dot; extra == "profiling"
Requires-Dist: graphviz; extra == "profiling"

```
Copyright 2024 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.
```
[![Regression tests](https://github.com/sandialabs/pyttb/actions/workflows/regression-tests.yml/badge.svg)](https://github.com/sandialabs/pyttb/actions/workflows/regression-tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/sandialabs/pyttb/badge.svg)](https://coveralls.io/github/sandialabs/pyttb)
[![pypi package](https://img.shields.io/pypi/v/pyttb?label=pypi%20package)](https://pypi.org/project/pyttb/)
[![image](https://img.shields.io/pypi/pyversions/pyttb.svg)](https://pypi.python.org/pypi/pyttb)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# pyttb: Python Tensor Toolbox

Welcome to `pyttb`, a refactor of the 
[Tensor Toolbox for MATLAB](https://www.tensortoolbox.org) 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`](https://pyttb.readthedocs.io/en/stable/tensor.html "dense tensors"), 
[`sptensor`](https://pyttb.readthedocs.io/en/stable/sptensor.html "sparse tensors"), 
[`ktensor`](https://pyttb.readthedocs.io/en/stable/ktensor.html "Kruskal tensors"), 
[`ttensor`](https://pyttb.readthedocs.io/en/stable/ttensor.html "Tucker tensors"), 
[`tenmat`](https://pyttb.readthedocs.io/en/stable/tenmat.html "matricized dense tensors"), 
[`sptenmat`](https://pyttb.readthedocs.io/en/stable/sptenmat.html "matricized sparse tensors"), 
[`sumtensor`](https://pyttb.readthedocs.io/en/stable/sumtensor.html "implicit sum of tensors")
- Algorithms:
[`cp_als`](https://pyttb.readthedocs.io/en/stable/cpals.html "CP decomposition via Alternating Least Squares"),
[`cp_apr`](https://pyttb.readthedocs.io/en/stable/cpapr.html "CP decomposition via Alternating Poisson Regression"), 
[`gcp_opt`](https://pyttb.readthedocs.io/en/stable/gcpopt.html "Generalized CP decomposition"), 
[`hosvd`](https://pyttb.readthedocs.io/en/stable/hosvd.html "Tucker decomposition via Higher Order Singular Value Decomposition"),
[`tucker_als`](https://pyttb.readthedocs.io/en/stable/tuckerals.html "Tucker decompostion via Alternating Least Squares")

## Quick Start

### Installation
```commandline
python3 -m pip install pyttb
```

### Example
```python
>>> 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
 ```

<!-- markdown-link-check-disable -->
### Getting Help
- [Documentation](https://pyttb.readthedocs.io)
- [Tutorials](https://pyttb.readthedocs.io/en/stable/tutorials.html)
- [Info for users coming from MATLAB](https://pyttb.readthedocs.io/en/stable/for_matlab_users.html)
- Learn about tensor decompositions: 
[tensor paper](https://doi.org/10.1137/07070111X "Tensor Decompositions and Applications by Tamara G. Kolda, Brett W. Bader"), 
[tensor book](https://www.mathsci.ai/post/tensor-textbook/ "Tensor Decompositions for Data Science by Grey Balard and Tamara G. Kolda") 
<!-- markdown-link-check-enable -->

### Contributing
- [Report a bug](https://github.com/sandialabs/pyttb/issues/new)
- [Guide for contributors](CONTRIBUTING.md)
- [List of contributors](CONTRIBUTORS.md)

### Citing pyttb in your work 
If you use pyttb in your work, please cite it using the citation info [here](CITATION.bib).
