Metadata-Version: 2.5
Name: nlls-gram
Version: 3.2.1
Summary: Levenberg-Marquardt and Gauss-Newton nonlinear least-squares for JAX
Project-URL: Homepage, https://github.com/HighDimensionalEconLab/nlls_gram
Project-URL: Repository, https://github.com/HighDimensionalEconLab/nlls_gram
Project-URL: Documentation, https://highdimensionaleconlab.github.io/nlls_gram/
Project-URL: Issues, https://github.com/HighDimensionalEconLab/nlls_gram/issues
Author-email: Jesse Perla <jesseperla@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: jax,levenberg-marquardt,nonlinear-least-squares,optimization,tikhonov
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.12
Requires-Dist: jax>=0.12.1
Requires-Dist: jaxlib>=0.12.1
Description-Content-Type: text/markdown

# nlls_gram

[![CI](https://github.com/HighDimensionalEconLab/nlls_gram/actions/workflows/ci.yml/badge.svg)](https://github.com/HighDimensionalEconLab/nlls_gram/actions/workflows/ci.yml)
[![Docs](https://github.com/HighDimensionalEconLab/nlls_gram/actions/workflows/docs.yml/badge.svg)](https://highdimensionaleconlab.github.io/nlls_gram/)
[![PyPI](https://img.shields.io/pypi/v/nlls-gram.svg)](https://pypi.org/project/nlls-gram/)
[![Python versions](https://img.shields.io/pypi/pyversions/nlls-gram.svg)](https://pypi.org/project/nlls-gram/)
[![License: MIT](https://img.shields.io/github/license/HighDimensionalEconLab/nlls_gram)](https://github.com/HighDimensionalEconLab/nlls_gram/blob/main/LICENSE)

Levenberg-Marquardt and Gauss-Newton nonlinear least squares for JAX pytrees, with generalized Tikhonov regularization, inequality and complementarity constraints, and implicit differentiation.

## Setup

```bash
uv add nlls-gram
```

For CUDA GPUs:

```bash
uv add nlls-gram "jax[cuda13]"
```

For local development:

```bash
uv sync --group dev --group docs --group benchmark
```

## Run

```python
import jax.numpy as jnp
from nlls_gram import LevenbergMarquardt

design = jnp.arange(24.0).reshape(4, 6)
y = jnp.ones(4)

solver = LevenbergMarquardt(lambda x, args, p: args["A"] @ x - p["y"])
result = solver.solve(jnp.zeros(6), {"A": design}, p={"y": y}, atol=1e-6)
```

Run tests, benchmarks, and docs:

```bash
uv run pytest -q
uv run pytest benchmarks/test_benchmarks.py --benchmark-only
uv run mkdocs build --strict
```

Documentation: <https://highdimensionaleconlab.github.io/nlls_gram/>
