Metadata-Version: 2.4
Name: sparse_grid
Version: 0.1.2
Summary: A Python Sparse Grid Package
Project-URL: homepage, https://eggzec.github.io/sparse_grid/
Project-URL: documentation, https://eggzec.github.io/sparse_grid/
Project-URL: source, https://github.com/eggzec/sparse_grid
Project-URL: releasenotes, https://github.com/eggzec/sparse_grid/releases/latest
Project-URL: issues, https://github.com/eggzec/sparse_grid/issues
Author-email: John Burkardt <jvb25@pitt.edu>
Maintainer-email: Saud Zahir <m.saud.zahir@gmail.com>, M Laraib Ali <laraibg786@outlook.com>
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: python,sparse grids
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# sparse_grid

**A Python Sparse Grid Package**

[![PyPI](https://img.shields.io/pypi/v/sparse_grid)](https://pypi.org/project/sparse_grid/)
[![License: BSD-3](https://img.shields.io/badge/License-BSD--3-blue.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)

`sparse_grid` is a pure-Python implementation of regular
[sparse grids](https://en.wikipedia.org/wiki/Sparse_grid)
over box domains. It provides hierarchical index generation, nodal-to-hierarchical
coefficient conversion, and fast function evaluation using the hat basis:

$$f_n(\mathbf{x}) = \sum_{\lvert\mathbf{l}\rvert_1 \le n+d-1} \sum_{\mathbf{p}} \alpha_{\mathbf{l},\mathbf{p}}\, \prod_{i=1}^{d} \phi_{l_i, p_i}(x_i)$$

## Quick example

```python
from sparse_grid import SparseGrid

sg = SparseGrid(dim=2, level=3)
sg.generate_points()

for index in sg.indices:
    pos = sg.g_p[tuple(index)].pos
    sg.g_p[tuple(index)].fv = (
        4.0 * pos[0] * (1.0 - pos[0]) * 4.0 * pos[1] * (1.0 - pos[1])
    )

sg.nodal_2_hier()
print(sg.eval_funct([0.25, 0.75]))
```

## Installation

```bash
pip install sparse_grid
```

Requires Python 3.10+. No external runtime dependencies. See the
[full installation guide](https://eggzec.github.io/sparse_grid/installation/) for
uv, poetry, and source builds.

## Documentation

- [Theory](https://eggzec.github.io/sparse_grid/theory/) — mathematical background, hierarchical basis, algorithms
- [Quickstart](https://eggzec.github.io/sparse_grid/quickstart/) — runnable examples
- [API Reference](https://eggzec.github.io/sparse_grid/api/) — class and function signatures
- [References](https://eggzec.github.io/sparse_grid/references/) — literature citations

## License

BSD-3-Clause — see [LICENSE](LICENSE).
