ndmap, 2022-2023
Higher order partial derivatives computation with respect to one or several tensor-like variables. Taylor series function approximation (derivative table and series function representation). Parametric fixed point computation.
Install & build
$ pip install git+https://github.com/i-a-morozov/ndmap.git@main
or
$ pip install ndmap -U
Documentation
https://i-a-morozov.github.io/ndmap/
Derivative (composable jacobian)
Compute higher order function (partial) derivatives.
>>> from ndmap.derivative import derivative
>>> def fn(x):
... return 1 + x + x**2 + x**3 + x**4 + x**5
...
>>> import torch
>>> x = torch.tensor(0.0)
>>> derivative(5, fn, x)
[tensor(1.), tensor(1.), tensor(2.), tensor(6.), tensor(24.), tensor(120.)]
>>> from ndmap.derivative import derivative
>>> def fn(x):
... x1, x2 = x
... return x1**2 + x1*x2 + x2**2
...
>>> import torch
>>> x = torch.tensor([0.0, 0.0])
>>> derivative(2, fn, x, intermediate=False)
tensor([[2., 1.],
[1., 2.]])
>>> from ndmap.derivative import derivative
>>> def fn(x, y):
... x1, x2 = x
... return x1**2*(1 + y) + x2**2*(1 - y)
...
>>> import torch
>>> x = torch.tensor([0.0, 0.0])
>>> y = torch.tensor(0.0)
>>> derivative((2, 1), fn, x, y)
[[tensor(0.), tensor(0.)], [tensor([0., 0.]), tensor([0., 0.])], [tensor([[2., 0.],
[0., 2.]]), tensor([[ 2., 0.],
[ 0., -2.]])]]
Derivative (gradient)
Compute higher order function (partial) derivatives.
>>> from ndmap.gradient import series
>>> def fn(x):
... return 1 + x + x**2 + x**3 + x**4 + x**5
...
>>> import torch
>>> x = torch.tensor([0.0])
>>> series((5, ), fn, x, retain=False, series=False)
{(0,): tensor([1.]),
(1,): tensor([1.]),
(2,): tensor([2.]),
(3,): tensor([6.]),
(4,): tensor([24.]),
(5,): tensor([120.])}
>>> from ndmap.gradient import series
>>> def fn(x):
... x1, x2 = x
... return x1**2 + x1*x2 + x2**2
...
>>> import torch
>>> x = torch.tensor([0.0, 0.0])
>>> series((2, ), fn, x, intermediate=False, retain=False, series=False)
{(2, 0): tensor(2.), (1, 1): tensor(1.), (0, 2): tensor(2.)}
>>> from ndmap.gradient import series
>>> def fn(x, y):
... x1, x2 = x
... y1, = y
... return x1**2*(1 + y1) + x2**2*(1 - y1)
...
>>> import torch
>>> x = torch.tensor([0.0, 0.0])
>>> y = torch.tensor([0.0])
>>> series((2, 1), fn, x, y, retain=False, series=False)
{(0, 0, 0): tensor(0.),
(0, 0, 1): tensor(0.),
(1, 0, 0): tensor(0.),
(0, 1, 0): tensor(0.),
(1, 0, 1): tensor(0.),
(0, 1, 1): tensor(-0.),
(2, 0, 0): tensor(2.),
(1, 1, 0): tensor(0.),
(0, 2, 0): tensor(2.),
(2, 0, 1): tensor(2.),
(1, 1, 1): tensor(0.),
(0, 2, 1): tensor(-2.)}
Desription
>>> import ndmap
>>> ndmap.__about__
Animations
Stable and unstable invariant manifolds approximation
Collision of fixed points
Reduce real part of a hyperbolic fixed point
Metadata
Release files for ndmap 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ndmap-0.1.7.tar.gz | 8.3 MB | Without provenance | Details for ndmap-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ndmap-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for ndmap-0.1.7-py3-none-any.whl |
Total release size: 8.3 MB
Release files / ndmap-0.1.7.tar.gz
| Download URL | ndmap-0.1.7.tar.gz |
|---|---|
| Size | 8.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e125ca121f828da43d4f331a1d91d971155292634df2f665182ef9a0a62fef3
|
|
BLAKE2b-256 checksum How to use checksums |
ac5c2bbbc5f65116fdfb281b547012fd4a1633ab80afddde9835a76ef7d89663
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.4
|
Release files / ndmap-0.1.7-py3-none-any.whl
| Download URL | ndmap-0.1.7-py3-none-any.whl |
|---|---|
| Size | 47.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c2c378db3ea1c5f9ed1ad0655e03715e2ca94560140a227915fe8b811028a58
|
|
BLAKE2b-256 checksum How to use checksums |
2cfb3e31395b86ae479a964acc13b66c92d37e9af4da9f94cffa323124a6e904
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.4
|
Security for ndmap 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.