Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

automatic calculation of sparse gradient

Project Description

# sparsegrad - automatic computation of sparse Jacobian matrices from `numpy` expressions

`sparsegrad` performs automatic differentiation of vector valued functions in Python. A significant subset of `numpy` operation is supported on Python scalars and `ndarrays` with dimensionality less than 2:

  • all arithmetic operators
  • all elementary functions
  • simple and fancy indexing
  • matrix-vector product `dot`, restricted to constant matrix
  • concatenation of vectors `stack`
  • vectorized selection `where`
  • sum reduction `sum`

Depending on use, `sparsegrad` can provide Jacobian matrix or sparsity pattern.

The primary use of `sparsegrad` is to automatically evaluate Jacobian matrices when solving non-linear systems of equations. `sparsegrad` uses forward mode automatic differentiation. In contrast to backward mode automatic differentiation, this allows to better control the memory usage of calculation.

`sparsegrad` is Python-only and requires only `numpy` and `scipy`. It works both in Python 2.7 and 3.x. In contrast to other pure Python automatic differentiation modules, `sparsegrad` attempts to be better suited for calculating moderately large sparse matrices. It has been used for solving problems with >1M equations and >20M nonzeros without causing bottleneck in terms of running time or memory usage.

For basic usage, see tutorial `doc/tutorial.ipynb`.

`sparsegrad` is not yet tested on many combinations of `numpy` and `scipy` versions. After installing, it is highly recommended to check if all tests pass by running:

` import sparsegrad sparsegrad.test() `

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(24.5 kB) Copy SHA256 Hash SHA256
Source Nov 22, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting