Name | ndmap JSON |
Version |
0.1.7
JSON |
| download |
home_page | |
Summary | Higher order partial derivatives computation with respect to one or several tensor-like variables, application to nonlinear dynamics |
upload_time | 2023-09-19 14:19:34 |
maintainer | |
docs_url | None |
author | Ivan Morozov |
requires_python | >=3.10 |
license | MIT |
keywords |
torch
derivative
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ndmap, 2022-2023
<p align="center">
<img width="100" height="100" src="https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/logo.svg">
</p>
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/](https://i-a-morozov.github.io/ndmap/)
# Derivative (composable jacobian)
Compute higher order function (partial) derivatives.
```python
>>> 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.)]
```
```python
>>> 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.]])
```
```python
>>> 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.
```python
>>> 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.])}
```
```python
>>> 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.)}
```
```python
>>> 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
```python
>>> import ndmap
>>> ndmap.__about__
```
# Animations
Stable and unstable invariant manifolds approximation
<p align="center">
<img width="576" height="576" src="https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/manifold.gif">
</p>
Collision of fixed points
<p align="center">
<img width="576" height="576" src="https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/collision.gif">
</p>
Reduce real part of a hyperbolic fixed point
<p align="center">
<img width="576" height="576" src="https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/change.gif">
</p>
Raw data
{
"_id": null,
"home_page": "",
"name": "ndmap",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "torch,derivative",
"author": "Ivan Morozov",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/ac/5c/2bbbc5f65116fdfb281b547012fd4a1633ab80afddde9835a76ef7d89663/ndmap-0.1.7.tar.gz",
"platform": null,
"description": "# ndmap, 2022-2023\n\n<p align=\"center\">\n <img width=\"100\" height=\"100\" src=\"https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/logo.svg\">\n</p>\n\nHigher order partial derivatives computation with respect to one or several tensor-like variables.\nTaylor series function approximation (derivative table and series function representation).\nParametric fixed point computation.\n\n# Install & build\n\n```\n$ pip install git+https://github.com/i-a-morozov/ndmap.git@main\n```\nor\n```\n$ pip install ndmap -U\n```\n\n# Documentation\n\n[https://i-a-morozov.github.io/ndmap/](https://i-a-morozov.github.io/ndmap/)\n\n# Derivative (composable jacobian)\n\nCompute higher order function (partial) derivatives.\n\n```python\n>>> from ndmap.derivative import derivative\n>>> def fn(x):\n... return 1 + x + x**2 + x**3 + x**4 + x**5\n... \n>>> import torch\n>>> x = torch.tensor(0.0)\n>>> derivative(5, fn, x)\n[tensor(1.), tensor(1.), tensor(2.), tensor(6.), tensor(24.), tensor(120.)]\n```\n\n```python\n>>> from ndmap.derivative import derivative\n>>> def fn(x):\n... x1, x2 = x\n... return x1**2 + x1*x2 + x2**2\n... \n>>> import torch\n>>> x = torch.tensor([0.0, 0.0])\n>>> derivative(2, fn, x, intermediate=False)\ntensor([[2., 1.],\n [1., 2.]])\n```\n\n```python\n>>> from ndmap.derivative import derivative\n>>> def fn(x, y):\n... x1, x2 = x\n... return x1**2*(1 + y) + x2**2*(1 - y)\n... \n>>> import torch\n>>> x = torch.tensor([0.0, 0.0])\n>>> y = torch.tensor(0.0)\n>>> derivative((2, 1), fn, x, y)\n[[tensor(0.), tensor(0.)], [tensor([0., 0.]), tensor([0., 0.])], [tensor([[2., 0.],\n [0., 2.]]), tensor([[ 2., 0.],\n [ 0., -2.]])]]\n```\n\n# Derivative (gradient)\n\nCompute higher order function (partial) derivatives.\n\n```python\n>>> from ndmap.gradient import series\n>>> def fn(x):\n... return 1 + x + x**2 + x**3 + x**4 + x**5\n... \n>>> import torch\n>>> x = torch.tensor([0.0])\n>>> series((5, ), fn, x, retain=False, series=False)\n{(0,): tensor([1.]),\n (1,): tensor([1.]),\n (2,): tensor([2.]),\n (3,): tensor([6.]),\n (4,): tensor([24.]),\n (5,): tensor([120.])}\n```\n\n```python\n>>> from ndmap.gradient import series\n>>> def fn(x):\n... x1, x2 = x\n... return x1**2 + x1*x2 + x2**2\n...\n>>> import torch\n>>> x = torch.tensor([0.0, 0.0])\n>>> series((2, ), fn, x, intermediate=False, retain=False, series=False)\n{(2, 0): tensor(2.), (1, 1): tensor(1.), (0, 2): tensor(2.)}\n\n```\n\n```python\n>>> from ndmap.gradient import series\n>>> def fn(x, y):\n... x1, x2 = x\n... y1, = y\n... return x1**2*(1 + y1) + x2**2*(1 - y1)\n...\n>>> import torch\n>>> x = torch.tensor([0.0, 0.0])\n>>> y = torch.tensor([0.0])\n>>> series((2, 1), fn, x, y, retain=False, series=False)\n{(0, 0, 0): tensor(0.),\n (0, 0, 1): tensor(0.),\n (1, 0, 0): tensor(0.),\n (0, 1, 0): tensor(0.),\n (1, 0, 1): tensor(0.),\n (0, 1, 1): tensor(-0.),\n (2, 0, 0): tensor(2.),\n (1, 1, 0): tensor(0.),\n (0, 2, 0): tensor(2.),\n (2, 0, 1): tensor(2.),\n (1, 1, 1): tensor(0.),\n (0, 2, 1): tensor(-2.)}\n```\n\n# Desription\n\n```python\n>>> import ndmap\n>>> ndmap.__about__\n```\n\n# Animations\n\nStable and unstable invariant manifolds approximation\n\n<p align=\"center\">\n <img width=\"576\" height=\"576\" src=\"https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/manifold.gif\">\n</p>\n\nCollision of fixed points\n\n<p align=\"center\">\n <img width=\"576\" height=\"576\" src=\"https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/collision.gif\">\n</p>\n\nReduce real part of a hyperbolic fixed point\n\n<p align=\"center\">\n <img width=\"576\" height=\"576\" src=\"https://github.com/i-a-morozov/ndmap/blob/main/docs/pics/change.gif\">\n</p>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Higher order partial derivatives computation with respect to one or several tensor-like variables, application to nonlinear dynamics",
"version": "0.1.7",
"project_urls": null,
"split_keywords": [
"torch",
"derivative"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2cfb3e31395b86ae479a964acc13b66c92d37e9af4da9f94cffa323124a6e904",
"md5": "00cb57d93ae28db8706bef5935cdcb0b",
"sha256": "2c2c378db3ea1c5f9ed1ad0655e03715e2ca94560140a227915fe8b811028a58"
},
"downloads": -1,
"filename": "ndmap-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "00cb57d93ae28db8706bef5935cdcb0b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 47505,
"upload_time": "2023-09-19T14:19:25",
"upload_time_iso_8601": "2023-09-19T14:19:25.597180Z",
"url": "https://files.pythonhosted.org/packages/2c/fb/3e31395b86ae479a964acc13b66c92d37e9af4da9f94cffa323124a6e904/ndmap-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ac5c2bbbc5f65116fdfb281b547012fd4a1633ab80afddde9835a76ef7d89663",
"md5": "cd67a872d59bd6fb980f27275e5d58dc",
"sha256": "3e125ca121f828da43d4f331a1d91d971155292634df2f665182ef9a0a62fef3"
},
"downloads": -1,
"filename": "ndmap-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "cd67a872d59bd6fb980f27275e5d58dc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 8292482,
"upload_time": "2023-09-19T14:19:34",
"upload_time_iso_8601": "2023-09-19T14:19:34.502175Z",
"url": "https://files.pythonhosted.org/packages/ac/5c/2bbbc5f65116fdfb281b547012fd4a1633ab80afddde9835a76ef7d89663/ndmap-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-19 14:19:34",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ndmap"
}