Commit 7b4c3f2d authored by Martin Bauer's avatar Martin Bauer
Browse files

Refactoring of plotting and stencil plotting

- stencil plotting & transformation now in ps.stencil
- additional documentation & notebooks
parent 0998f2e1
[flake8]
max-line-length=120
exclude=pystencils/jupytersetup.py,
pystencils/plot2d.py
exclude=pystencils/jupyter.py,
pystencils/plot.py
pystencils/session.py
ignore = W293 W503 W291
%% Cell type:code id: tags:
``` python
from pystencils.session import *
```
%% Cell type:markdown id: tags:
# Tutorial 01: Getting Started
## Overview
*pystencils* is a package that can speed up computations on *numpy* arrays. All computations are carried out fully parallel on CPUs (single node with OpenMP, multiple nodes with MPI) or on GPUs.
It is suited for applications that run the same operation on *numpy* arrays multiple times. It can be used to accelerate computations on images or voxel fields. Its main application, however, are numerical simulations using finite differences, finite volumes, or lattice Boltzmann methods.
There already exist a variety of packages to speed up numeric Python code. One could use pure numpy or solutions that compile your code, like *Cython* and *numba*. See [this page](demo_benchmark.ipynb) for a comparison of these tools.
![Stencil](../img/pystencils_stencil_four_points_with_arrows.svg)
As the name suggests, *pystencils* was developed for **stencil codes**, i.e. operations that update array elements using only a local neighborhood.
It generates C code, compiles it behind the scenes, and lets you call the compiled C function as if it was a native Python function.
But lets not dive too deep into the concepts of *pystencils* here, they are covered in detail in the following tutorials. Let's instead look at a simple example, that computes the average neighbor values of a *numpy* array. Therefor we first create two rather large arrays for input and output:
%% Cell type:code id: tags:
``` python
input_arr = np.random.rand(1024, 1024)
output_arr = np.zeros_like(input_arr)
```
%% Cell type:markdown id: tags:
We first implement a version of this algorithm using pure numpy and benchmark it.
%% Cell type:code id: tags:
``` python
def numpy_kernel():
output_arr[1:-1, 1:-1] = input_arr[2:, 1:-1] + input_arr[:-2, 1:-1] + \
input_arr[1:-1, 2:] + input_arr[1:-1, :-2]
```
%% Cell type:code id: tags:
``` python
%%timeit
numpy_kernel()
```
%%%% Output: stream
3.84 ms ± 36.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
3.93 ms ± 40 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
%% Cell type:markdown id: tags:
Now lets see how to run the same algorithm with *pystencils*.
%% Cell type:code id: tags:
``` python
src, dst = ps.fields(src=input_arr, dst=output_arr)
symbolic_description = ps.Assignment(dst[0,0],
(src[1, 0] + src[-1, 0] + src[0, 1] + src[0, -1]) / 4)
symbolic_description
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdkAAAAoCAYAAACy/oAKAAAACXBIWXMAAA7EAAAOxAGVKw4bAAANAUlEQVR4Ae2di3HdNhaGJY0L0Ho78HagdTpwOnA2FSTuwBlXkHE68KaC2OnA7mAdd+B0kFgdeP8PAigQF3w/gEsdzOASjwPg8P8BHgIgeS+/fv16Ya4+BC4vL19Lq7+8Zrc6fhRXn4gr75kON/LfyP8g/9THdbi4kNwvLhD9JPWR8yHUF4lZcCYCCb6L+ErqQiPjaiYvuWIJvou4ov6kPpKML1DIuASrRdgnddFanbhjZM3XhYE6yx/yN4EXhd/Lv4nirwn7dGSfR/EvQc6nPVH+5yATyf0Ry4Ww5J6EcA1H6dPgUIM+OR2k4yp8gb28cbXhNWktrugHNfElXWycaBx2jM/NrmljcDcDu+GAzhE+lOYHrsTuDT9Eyl+T5sPBqHJBfhdkFXYz3BD38sg4oxzSKSPv6ghpXrYlF+dNCatu9H0/toxkX8ozc3fHuJzSnss/i9NqCks3DKNUWs6X6pnNlcp2YhjrtkZYbWX5VfqD4Qoc5Xbny7BfhrvnLdt/u8aGMO8cW8ob7PNmZKOLYxfIe6aLtGt5etIX+TfyLQOjeDC2Qa6VH+vqy1OXKxPnpWHJYHgX3fGpPJ0XnfGf0zZyccn9KN8Yd4XptM2NA2XkqG+Rbrm210iTXoGHRXz5c5zFlcoOYrjSuQ7y68/j0FxFfXI3voSrYX9/LZiL+yCG6TgZM7aG+rwZ2cqMrB/AzEhZIqYz4U9mhUrDGEn8fgaVhpXPhf+kbEaOztcYujR/alx1of9YI8tsoHWjoHhrECmOIWsZ3qk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O+WMq/pIMk7KcVIT9kWNrGZIPL32twBhSXKUmzGrwlDY6zej0L0XEifsf7MnbsvE97BUGTKu6qPFOCnHSW3Yl9yTdSzoIp5+xGJVdlR/5x7vqg0dr7JXws5uTs6DV+OqPp6Mk3KcVIV90ZlsOQ6s5T4EdCfIvjffejZXOQLGVX0EGSflOKkRezOy5fpDlS2rk7JMzLeqJz1cVuXJHFwp46o+go2TcpzUiv2lLqblULGWq0NAHZVZ7PfyfJUrduxt8yrPW/nPtgwfQ1MmbFyVwb2vVeOkD51t82rF3ozstrwfpnZ14C86mQ8yrvHHQQ5zfkc6EeOqPjaNk3KclMbelovLcX+OLbOUbO48EDCu6uPJOCnHSTHszciWI/0sWtZdIO8y81eHdNJnCr+Td39feBYn8ICUNK7qI9s4KcdJLdjbcnG5PmAtGwKGgCFgCBwcgf8DpsUufKsWZaMAAAAASUVORK5CYII=)
$\displaystyle {{dst}_{(0,0)}} \leftarrow \frac{{{src}_{(-1,0)}}}{4} + \frac{{{src}_{(0,-1)}}}{4} + \frac{{{src}_{(0,1)}}}{4} + \frac{{{src}_{(1,0)}}}{4}$
src_W src_S src_N src_E
dst_C := ───── + ───── + ───── + ─────
4 4 4 4
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(3,3))
ps.visualize_stencil_expression(symbolic_description.rhs)
ps.stencil.plot_expression(symbolic_description.rhs)
```
%%%% Output: display_data
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANoAAADTCAYAAADnEg0TAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAClpJREFUeJzt3W9sVWcdwPHv0z+X0tLC4I7hUGZchluiiTFxMdmcm7qRS7Y5/JNg3AvFxAjTSDRzJMZk0akkRoPGzMRIfLGgkTmXbHEdL/ybEaPGF1OjYwwWUNDJZ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xaH/t60y3XsHnb/wqcRviIVn4P//5A0SPI0KQQhjb3vZ4PQR2efBfNBEOb++qT7zIrx2oaDG2Oy7Xqc8DBJg7dn2tVL80KYmjlsBHYM439/wlsmqVZdAH+kosSSb31q4GlwMWuuxoGjuVa9XDcVAJDk0J46igFMDQpwP8BiJCQfoddbocAAAAASUVORK5CYII=)
%% Cell type:markdown id: tags:
Here we first have created a symbolic notation of the stencil itself. This representation is built on top of *sympy* and is explained in detail in the next section.
This description is then compiled and loaded as a Python function.
%% Cell type:code id: tags:
``` python
kernel = ps.create_kernel(symbolic_description).compile()
```
%% Cell type:markdown id: tags:
This whole process might seem overly complicated. We have already spent more lines of code than we needed for the *numpy* implementation and don't have anything running yet! However, this multi-stage process of formulating the algorithm symbolically, and just in the end actually running it, is what makes *pystencils* faster and more flexible than other approaches.
Now finally lets benchmark the *pystencils* kernel.
%% Cell type:code id: tags:
``` python
def pystencils_kernel():
kernel(src=input_arr, dst=output_arr)
```
%% Cell type:code id: tags:
``` python
%%timeit
pystencils_kernel()
```
%%%% Output: stream
639 µs ± 35 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
643 µs ± 8.66 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
%% Cell type:markdown id: tags:
This benchmark shows that *pystencils* is a lot faster than pure *numpy*, especially for large arrays.
If you are interested in performance details and comparison to other packages like Cython, have a look at [this page](demo_benchmark.ipynb).
%% Cell type:markdown id: tags:
## Short *sympy* introduction
In this tutorial we continue with a short *sympy* introduction, since the symbolic kernel definition is built on top of this package. If you already know *sympy* you can skip this section.
You can also read the full [sympy documentation here](http://docs.sympy.org/latest/index.html).
%% Cell type:code id: tags:
``` python
import sympy as sp
sp.init_printing() # enable nice LaTeX output
```
%% Cell type:markdown id: tags:
*sympy* is a package for symbolic calculation. So first we need some symbols:
%% Cell type:code id: tags:
``` python
x = sp.Symbol("x")
y = sp.Symbol("y")
type(x)
```
%%%% Output: execute_result
sympy.core.symbol.Symbol
%% Cell type:markdown id: tags:
The usual mathematical operations are defined for symbols:
%% Cell type:code id: tags:
``` python
expr = x**2 * ( y + x + 5) + x**2
expr
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAAAZCAYAAAChKLVZAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFdklEQVR4Ae2bgVHcMBBFOYYCSFJBoAMgHUAHUEKgA5hUwEAHJB2EdABUEKADSAWE64D8p0ge2ZaNvfb57sCaMbJW0mr3a7Urycfk5eVlxZImk8mZ+q3r2dDzqOdEvKbKxzQiYEagyq4mFkP1zC7UFwNdUflS2YbK22YJx47vHoE6u1o1orNf6Heq8pYGwruOaUTAikClXVkNFUFiowwhP6ZZhR37vW8EYhvK7GrNgolC/Gah35Yv3xboY3FEoDECdXbVxaPGAnCwanWYYpug5zBmMr73g4Bw3X8j27DMrkyHqRhOAeJO/1oNRzG97l19uC24VJ+9unZjXRkBYXcn6oWen8JvqjLRDOyvVP6l3CXROeDiPNyB15OXJpP8ObvqZKhihkfcFhiNjRSk1A+wD5YVRHSYVxJ2zxqbhR6nc2F5EhPUjjY3oi/dTUzKrsyhX8x2BcRmMFLKesJeNcYs9+6FuB3KSDUeYfA4J8QcCz3Ig4c814P3xDiZg5yRirYiGgeR66669yAv4jROGi9pV6bDlJhhkLjmUxTxUuBVD/x7XQaoY8ivQ6i+7jFlmBVdTkX/owfDXvhUZ1cmQ5XGN3rcPjPW3q/imJR7lyDu6kHtlnLflFNmCQrMhzB/1LOr9+slELnSrjJDlTIYXjiFf9E7ng/Dwnt+0vMkZd3KVP5BZUvC+1YC1kYGy+Bt+0TycB33EPSHj+rAhr32Z9EJs4MljR3miTlDNr4S3lcIAN5EukrcK/r1Qo4whJ/drqQgDFD4jHdfBogHPce+zPtdqLfm4nGl5zDVX/SZyCC+LA6nR2rcOpr6OUyUs296jtvCU49I/zFrmquPWR7GUALD9TCe3lkwVOA13fzFuejMpXnu1Ncsr/r2NqfBo34TU/YzIbFKAeC7J7D/7CNcw/Ov51nMhpKhOG6y7D3mb1+JRyrqzz57cC8lI8zt71UmtCMHV1bFDzEiObwxmHmk3ubUXU/hnqXwNGiiMquW1ZkDJdRbc/HlaoVrqdIEd5VB/Tnc4fmKiUn6qKdoaLTjYIIRllIsj5f7VG2zQ4loeDHuKTNazKRveWLexXeNhZHiObkByOmpOrZueNRJsV9cnoW84tmfXUmBVLhgEkzhMsUv0MQTQ02GqNAm5GrXiwziYw5dyIK8XpY43DL5VG4FeZvm6mOWR325xC+FcdFYpMhTwlY0J2tT+Yrt1N8sb4KXeU5XJUgu+RUIreT1cg1tBcL+q2FoxjK0lRyPey/Qs4ijMsY7Fa3qANN2jKbtUxGDvgHT1G8tqqJJ0zF7add1Tp2higmX4kFZB0Y8Cao7juq7CE5YArhSGlCG0tivENhX58KpynPZn2pcPpumvjQxZ8XFJJJLyB8vMk+efdbnnK6KGUoSUsJqze1LVe8ULXgUq5Z4oBLQA8vQVvackXpZwcrt49sy69j+TOOzH82SyuxNWfzJvbbo4D2L6Ci21anvOV3TUIQLPsfxayauXFD40APCPSF72HD6p9glMbk5oD2zIWVoKz/3yT88NvQNJ+vBJ1/zwAk/GCteEifCdqruLndH9V/1DJ16ndNOP0qxaC6guZPdA3RL/7Z9NB6HAf5NJnk6N/Bjoe2IXykyNOHVtzx1Y2ostnMcvsLiqmuerBtS3qQAnjgPQyVUtf7FVZ0SdXV+sogKrfdp6suWKPtfMM+LmwsWmsmjdpGnTs9UncbiNuBJspoX6ZDypnQItMENlYGlPFuAIwE4iFcNyrbNJSfen69Tbuvj5eZ3n+aJbyuDtb03sKX8mV9K53kZKiFp4X84rcnm0MQ9JInwWfdN3TValD9+US28M2iK11wMFeEEJAcBLqj7Oqg11fnNtxO2bK+uFz1itZmIf3yMaza5icDpAAAAAElFTkSuQmCC)
$\displaystyle x^{2} \left(x + y + 5\right) + x^{2}$
2 2
x ⋅(x + y + 5) + x
%% Cell type:markdown id: tags:
Now we can do all sorts of operations on these expressions: expand them, factor them, substitute variables:
%% Cell type:code id: tags:
``` python
expr.expand()
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIYAAAAYCAYAAAA/FYWiAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEqElEQVRoBeWagVUUMRCGOZ4FoFYgdIBagdIBagVoB/isgIcdoBUodqBWINABdIBcB/h9YbMvt+zevd3N3cXHvDdkk1xm/kwmmckuk9vb240hNJlMjhl3De/AT+ADZE0pi6cK+xZAt+Er+OP/gj23cTttoWP0ZcCdwO/juKr+M9ZLLsGqQ29HjDyfwuex/pDKebbYpHMoeVJEOufhdawUXu438B1R32XneHo8NOq0xaMhlmBXfWiMe079V6Ot5GoMIWKM4S9tKxl7bmzpvGtbDHKMFBk7zVj9Fn6Vtpf6jFOnJ50wdyusZ6ViXhauebbYHKMUpzhk/G/4CCUXY2Stcaw5x4NNPht2r20xYUEbff2rOIjJqAndXv/R6xsBbg2xBe5maFwfqAWaK8zeBqWn8Lccm/KeLXSMsQw445Qetj9W1qrGg/U9fLIqfWP1gNWQHZL8KEv8tsX60BIZ92zRO5TgWVvwDRxjM3Jr8n1Gb0LWPmxYWgmhyxvUDoYMJ4V1uG0+2fAgf+wcvVafgTlN8t2Qf8eA7LJF7+QTYFOECSZmsOLS0Na/WymZKgcwhBy5WBVWHeRNqbirxQvOnGJkLUaF7nm26O0YFTCN+AHBxjrjnJ77XKehLJ1Mlj2W3YE1FY79I0CnYPQtbU7qtEXtGCyyxjLWSC9hwbjgHrEu/jXAPlOak3gDKeYW0hP7Y+cwjxJ5Xm0v47wdQ582MdY/o31VG8HT4gLdrsU72A0ptlMwpKFFfH3WsdsWCEZ+2EHHPld1HeQSPqzqPo9OcqL8Zolsj/Sgq9m3qM44DZEVe5RH6YLcpBiomwvR1C9pZ8ygOTLO+blIOmP9GUL9kOtSJ/w8Z7NFdIR4bUvravYqRxEMVH9f6GuURb9H/iCjVdiyYgeLJ0IwNuW9rJ+2n/KiOTX7lQn3dn7GRMdA5Kwz0ie+G39jH5TNFuE9hscPgqdKlqg7eZ1kVHKjjJSQK3B3YZOcvDeathh6BY7OxDA39lQezxrdl3chhAqaNlfAF2J1m+2R6F/GHNWpHWbe2qIrXDPp26PvF/V864jAcEqkJYoE0tu7Uxl9ntE1aDe16ciFHTk6sHYIu1FdkDHeh9023fPaGDN4joxtDeW06xjimQkxEUfVN2gdNxk8Q3idk5dmkpq7prL/ZsbuKXWBkeuTlLrOMqVt1Ym3+gxxXXTvpB1ri+AYCPHli8e5FI76dPL0HSb9d78q5O8SsbsQTYMbWtexYY7Q64vFuEbR+n7V1lEDppy22ESYjuCdPjgE5UxeQb8GUnm6c2haPy0Z+4xTVLq0Uci/Vjn7apP+QOenqBc8OolftQ9sy22LCTJV8BX+A0tfYGOXiY5XJHMQ25ZGTMr4662nNaHrUlwZZynYW2Rrj2AXcM44TRe+tH3oHBsywq2DNjepG7b+qt2Cd9Q6Zvm6moIf8pzDaEP09hkDRq+GL3AKj+/e9D/MMZ1UKY7hqeXJ5E5YO7GIhlZPsOAE1MXn1TVcC4cArGQUM8dFc3i06Aer6C/FIZK5ejPz2I6ko/juYnDiWeAc49xayyJOjFZka2xkd5tkxmu7uYX/t7HqK+oaLbCx8Q9xlEVrw3lWOQAAAABJRU5ErkJggg==)
$\displaystyle x^{3} + x^{2} y + 6 x^{2}$
3 2 2
x + x ⋅y + 6⋅x
%% Cell type:code id: tags:
``` python
expr.factor()
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHoAAAAZCAYAAAD+OToQAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE6klEQVRoBe2ai3EUORBAvS4C8HERHM7AHBlABvZdBEAGpojABRkAEVxBBvgiADsDTASAMzDvaaUtjXZm16OZXW/BdJWsX3er1a1utcY7u7m52auB2Wz2CroDygPKFeUFvK6pJ9hBDcxqDB2N/AZaDbxH/z3VA/oPd3CPk0hoYL9SC8cF3Rn9Iwyud0+wgxqoNb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mGvoI3jBxlVVchj+nLbAh+dL4P8DBxDYA8Oug/lKfzkaW/6vt8xh8R31FShmlGZ8z3wjeV9w4qszyHe0NUkt/Gy2RiYzKwpnei39Vbk6Z1m4iKzPWj7EE/8GwcgnW8nB8qT+QR/pFE+5qiI5ootl4jrKcNnw7+7xVMegELm1CYHfZWUq+FIvIYis3XhZ/Z7d/IvxSZcryu9tjydK3jOGvpQCZvh3dhaL3hIYv7Nt84xM0alTz9vQBar7TFb+EiL18OS8+Y2zIeIs9t10h4rKXnz79oooBez4Mx8Fnc+23n/02JjEafxZMlyj36s3MMnZY8kDV5c7Dv1j0aAVJI2fkfHuARJl2+QwXvZvOL1rswYOzQH2TXmZ4jb7gi78TQ6gNBTCL8eDJKoifPCeYaQLdej34OXeRBPwGnY432F5GebwAAAABJRU5ErkJggg==)
$\displaystyle x^{2} \left(x + y + 6\right)$
2
x ⋅(x + y + 6)
%% Cell type:code id: tags:
``` python
expr.subs(y, sp.cos(x))
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANoAAAAZCAYAAABXYTDBAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGi0lEQVR4Ae2bjXHVOBSF8zIUwEIH0AGwFSx0EJYKCB2EoQImdAB0AHRAqGCTdEC2grDpIHs+ja7jH8nPT5btZ2zNaKzfq6Mj3asrvWRze3t7kBI2m82p+t1XfKR4pfhWsm70XcPKwGIZiOnFJkXRvLCP6ouCHSj/VZ9Hyj9dLMPrxBfPQJteHCayc1Tr9175JxqI020NKwNLZSCqF6mKBpFlpTKXsVy2VLLXeS+bgbIOFHpxL4UTuYiPa/2e+Px5rXzNrgwshoE2vehzopUJ5GFkp8cQ3EzF47KQNR1noC9f6n+EjPgI+1UzN7wR9u70Qlp40CdqAITxMNJZjtrzWvl9lz5LbpuLL8mxR6vOazUE78JxoYiRvY98BTyij4pH5fGU3wu8ZUxd08Je0YukV0cJcUFWB7KeavA3vqjTR/0g+qX6uVfLTp0W3CgX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zyh+LrgQYw7DbWWN/YfI3D8wCQKfE6OH33pFM0CeFHXZuoI0Kb4dImrLqTUr0Vp3xZXEhrhBExNMYOFWj+NyqHg2ehevB6jmjXcLFVjxUmYMFRNNyiIqgv91/cTaeERUU1MRRfjAnuKcIXzT300sq+u/S813FNgjfnnjyUMCbIZjBLU9k0qneTjBBQJ2Rbno3bIHlkDNswluu5vzX++Fl4cXPMEP2l9N8qM8Wy/p+V4H5mnsE7tTFjZm3IW72Vlb9D8cUatI1bxpA7fSoeKo9AymOEMMDB+7LKR8crTFn1AheGxWZT/KNIwNK6S6m+3Ce4w9nrI9nk4MFzL6m4YyofDINkc5/g6T3pLyFK2H5JDg8aDxWZQ+F6qQ3GiFfGG0UC8/mqNm4zq55Fw4DRnzrawUHltzblK8H3y86X5LKur4XPjEVl3G0Z9e/LaZkv0nAb/e+PKfBqTNYpm170+qPibQsSqtcE2Gwvyhs11C5XWd9NkQtHqpzcfPkNxGNExdjtgm9MTueGN8bjFIrGabnzX/zHJrCt3C8UpzKnyOyC8GflS/Jwe6/FR9IJD4Fjcjo3vLENNrqi+YXi94g3Y51qscnPpVybLQtfXkEm/zeZrrzPDW/bvA7bKges49JbuRAPONbvIDoXXzx6xR4c9pGnueGNcjjJiQYaWSsuwfzQm+WhJTrD36SiL1/qjwt6NhcvYm54t22z/wEpCTBaXuAzLwAAAABJRU5ErkJggg==)
$\displaystyle x^{2} \left(x + \cos{\left(x \right)} + 5\right) + x^{2}$
2 2
x ⋅(x + cos(x) + 5) + x
%% Cell type:markdown id: tags:
We can also built equations and solve them
%% Cell type:code id: tags:
``` python
eq = sp.Eq(expr, 1)
eq
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANAAAAAZCAYAAABAQ6AIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGKUlEQVR4Ae2cj3HUOBSHswwFwF0FQAeB6yB0ACUAHcBQQSZ0AHQAdEBSwRE6SKjgIB3kvs+RPbbX9tqyrf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hlPwH1M38ID0eYVst9ZirYykanxlGnXn5lL4zGs81a0sk7eGYKf076qjyvX58ALzSR6VV7HnM+sRx7L64fw88ZeeNBQKpkOKofXn5X2sXVoakAeaDfSnQoDdAy1otci3oBFZchwU1cp5dFh3ta3ZEw0HsYaRmoMFf7R5uYhnjXe0pZhrY/pW2d8NN76HAFjtCzq9FLXwa8ByedCF/IQjrabFHYsK2teInQZU/QKJ2bGMBS/Huonwio8NHWN6oq2toP70Dn69nfeiocJA/WypqbfIrZ535sRif6dW6bQb4tAulbYGoF0DSq/ywyIyd1lToOSKCR3uEI5eP+Wpk81JbLb0KTwFehaSohhbe4NDZ6F6kq7lfMPOLw8aDr0KrO6kefLEn/Z+PP22cuUMoUvWzkD3WORMt/QIDMcysq5h/eZACYwHgWmUa790V1iDOIYkirGE7DKq+ycOITQBH1PmN8YvEjUDSvclBrPcrTL7zmiCci2p4XLtB1495vc0xe97vOk2/dHiP46Wk+jIF4HQfmdQ2+U38ZZHZOyq/EGAikxNEzf2eTO9jnwxo75TVdypUQO3rjlRqRXcXMzLO76FvWM96/IqdOSZTqIF8EW3KRyJ3NGm+s7H/1r7EFI6MzEfpfwm0VlZx9Kp29/5jM8ney3cIGZz8C/5kn7YJoaT9eczOWO6aVDbvRd3RvfpcTbCGDhjdswIEOOpwi1KZafnF1BifSig88BjDW0Lf6vh0DLm8S2j5Yb8Y/Bs5F4rQNzebAufkFSe92rmhJvL0AL65TcgFw/QjGUe4NSJ/FCsTwHp97yBJxZCBtw+3c3jd9+YueZY1xQ/DOwRnnKOTDdRprbMiBDi8X/QR1KaMx7GARvGNT1m7PQbRlFMPbFb1LL4FY8iq0YkHARsAdgP/xNdUERz4VbNhLeGib7WWLRHv42sP1//R3DyYnQa4YAAAAASUVORK5CYII=)
$\displaystyle x^{2} \left(x + y + 5\right) + x^{2} = 1$
2 2
x ⋅(x + y + 5) + x = 1
%% Cell type:code id: tags:
``` python
sp.solve(sp.Eq(expr, 1), y)
```
%%%% Output: execute_result
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PF++RTQcW8BVD07PTy1f/biQu5S7cX65X1PrSQa+GAFsTtIK0OW/O0RROrMPYc9SwcoSl9zgw6LHGC1IvCCwH3L82Vo2JL6xQdg5Hcsh3y252jbaZsKecuuEkIdikqNPjJ4jhbmhwrjqieGyxU10clK7BwjO8cLgYyB+U/xEKyVnIk4D2BrI0xNa7UH9wv6Yu3wlA1+NI9Sylbu0QeR7F8sXf5XGW6z6W6yHgeuB9lo0jJvKSjLwp7a4ngkrsRM0gN/dT0i03qhG684lA3+uiOZncFpufsb0ObABOKX0GmBmixszUy0xGwlgw4hZDtBqL60GfjbwTmdUwHMyORDwHJfXJlP7tUXVTkYBOVBLtW9BlX9P+bc98O6bX1aptXPhZ1m46GDrZW6FMhAOAH/hcVCYQcDN5wlxLsyjzQInfWPgsW1my+cdt6ZogalYKp1yrzbzJYUPRHVuQf22DrY50GHAcJg2IQFfy+Az8Cci+xCBhW5BBfKnJlybwddEepHLVsxY1nPUeBIy8JOItXmlMtz8gU2yAyQDvzlO0WoQ4K3eghr40aBrVpHborV6C2oGXzPMYpZu/RbUwI8JX4O6nLHX6i2oqf0GgOVe1MDPHcEG/Bv4DYSXe1G/5vPUKjwStJ9czx3ZgH9hyxHwVhA1JOx/b5/EkOw/WwilkXlY4HPXX/4T8tF/Lpu0ZsotEIsAAAAASUVORK5CYII=)
$\displaystyle \left[ - x - 6 + \frac{1}{x^{2}}\right]$
⎡ 1 ⎤
⎢-x - 6 + ──⎥
⎢ 2⎥
⎣ x ⎦
%% Cell type:markdown id: tags:
A *sympy* expression is represented by an abstract syntax tree (AST), which can be inspected and modified.
%% Cell type:code id: tags:
``` python
expr
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAAAZCAYAAAChKLVZAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFdklEQVR4Ae2bgVHcMBBFOYYCSFJBoAMgHUAHUEKgA5hUwEAHJB2EdABUEKADSAWE64D8p0ge2ZaNvfb57sCaMb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G4FeZvm6mOWR325xC+FcdFYpMhTwlY0J2tT+Yrt1N8sb4KXeU5XJUgu+RUIreT1cg1tBcL+q2FoxjK0lRyPey/Qs4ijMsY7Fa3qANN2jKbtUxGDvgHT1G8tqqJJ0zF7add1Tp2higmX4kFZB0Y8Cao7juq7CE5YArhSGlCG0tivENhX58KpynPZn2pcPpumvjQxZ8XFJJJLyB8vMk+efdbnnK6KGUoSUsJqze1LVe8ULXgUq5Z4oBLQA8vQVvackXpZwcrt49sy69j+TOOzH82SyuxNWfzJvbbo4D2L6Ci21anvOV3TUIQLPsfxayauXFD40APCPSF72HD6p9glMbk5oD2zIWVoKz/3yT88NvQNJ+vBJ1/zwAk/GCteEifCdqruLndH9V/1DJ16ndNOP0qxaC6guZPdA3RL/7Z9NB6HAf5NJnk6N/Bjoe2IXykyNOHVtzx1Y2ostnMcvsLiqmuerBtS3qQAnjgPQyVUtf7FVZ0SdXV+sogKrfdp6suWKPtfMM+LmwsWmsmjdpGnTs9UncbiNuBJspoX6ZDypnQItMENlYGlPFuAIwE4iFcNyrbNJSfen69Tbuvj5eZ3n+aJbyuDtb03sKX8mV9K53kZKiFp4X84rcnm0MQ9JInwWfdN3TValD9+US28M2iK11wMFeEEJAcBLqj7Oqg11fnNtxO2bK+uFz1itZmIf3yMaza5icDpAAAAAElFTkSuQmCC)
$\displaystyle x^{2} \left(x + y + 5\right) + x^{2}$
2 2
x ⋅(x + y + 5) + x
%% Cell type:code id: tags:
``` python
ps.to_dot(expr, graph_style={'size': "9.5,12.5"} )
```
%%%% Output: execute_result
![](data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!-- Generated by graphviz version 2.40.1 (20161225.0304)--><!-- Title: %3 Pages: 1 --><svg width="422pt" height="260pt"viewBox="0.00 0.00 422.00 260.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 256)"><title>%3</title><polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-256 418,-256 418,4 -4,4"/><!-- Add(Pow(Symbol(x), Integer(2)), Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y))))_() --><g id="node1" class="node"><title>Add(Pow(Symbol(x), Integer(2)), Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y))))_()</title><ellipse fill="none" stroke="#000000" cx="135" cy="-234" rx="27" ry="18"/><text text-anchor="middle" x="135" y="-230.3" font-family="Times,serif" font-size="14.00" fill="#000000">Add</text></g><!-- Pow(Symbol(x), Integer(2))_(0,) --><g id="node2" class="node"><title>Pow(Symbol(x), Integer(2))_(0,)</title><ellipse fill="none" stroke="#000000" cx="99" cy="-162" rx="27" ry="18"/><text text-anchor="middle" x="99" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">Pow</text></g><!-- Add(Pow(Symbol(x), Integer(2)), Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y))))_()&#45;&gt;Pow(Symbol(x), Integer(2))_(0,) --><g id="edge1" class="edge"><title>Add(Pow(Symbol(x), Integer(2)), Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y))))_()&#45;&gt;Pow(Symbol(x), Integer(2))_(0,)</title><path fill="none" stroke="#000000" d="M126.2854,-216.5708C122.0403,-208.0807 116.8464,-197.6929 112.1337,-188.2674"/><polygon fill="#000000" stroke="#000000" points="115.237,-186.6477 107.6343,-179.2687 108.976,-189.7782 115.237,-186.6477"/></g><!-- Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,) --><g id="node5" class="node"><title>Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,)</title><ellipse fill="none" stroke="#000000" cx="171" cy="-162" rx="27" ry="18"/><text text-anchor="middle" x="171" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">Mul</text></g><!-- Add(Pow(Symbol(x), Integer(2)), Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y))))_()&#45;&gt;Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,) --><g id="edge2" class="edge"><title>Add(Pow(Symbol(x), Integer(2)), Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y))))_()&#45;&gt;Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,)</title><path fill="none" stroke="#000000" d="M143.7146,-216.5708C147.9597,-208.0807 153.1536,-197.6929 157.8663,-188.2674"/><polygon fill="#000000" stroke="#000000" points="161.024,-189.7782 162.3657,-179.2687 154.763,-186.6477 161.024,-189.7782"/></g><!-- Symbol(x)_(0, 0) --><g id="node3" class="node"><title>Symbol(x)_(0, 0)</title><ellipse fill="none" stroke="#000000" cx="27" cy="-90" rx="27" ry="18"/><text text-anchor="middle" x="27" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">x</text></g><!-- Pow(Symbol(x), Integer(2))_(0,)&#45;&gt;Symbol(x)_(0, 0) --><g id="edge3" class="edge"><title>Pow(Symbol(x), Integer(2))_(0,)&#45;&gt;Symbol(x)_(0, 0)</title><path fill="none" stroke="#000000" d="M83.7307,-146.7307C73.803,-136.803 60.6847,-123.6847 49.5637,-112.5637"/><polygon fill="#000000" stroke="#000000" points="51.7933,-109.8436 42.2473,-105.2473 46.8436,-114.7933 51.7933,-109.8436"/></g><!-- Integer(2)_(0, 1) --><g id="node4" class="node"><title>Integer(2)_(0, 1)</title><ellipse fill="none" stroke="#000000" cx="99" cy="-90" rx="27" ry="18"/><text text-anchor="middle" x="99" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">2</text></g><!-- Pow(Symbol(x), Integer(2))_(0,)&#45;&gt;Integer(2)_(0, 1) --><g id="edge4" class="edge"><title>Pow(Symbol(x), Integer(2))_(0,)&#45;&gt;Integer(2)_(0, 1)</title><path fill="none" stroke="#000000" d="M99,-143.8314C99,-136.131 99,-126.9743 99,-118.4166"/><polygon fill="#000000" stroke="#000000" points="102.5001,-118.4132 99,-108.4133 95.5001,-118.4133 102.5001,-118.4132"/></g><!-- Pow(Symbol(x), Integer(2))_(1, 0) --><g id="node6" class="node"><title>Pow(Symbol(x), Integer(2))_(1, 0)</title><ellipse fill="none" stroke="#000000" cx="171" cy="-90" rx="27" ry="18"/><text text-anchor="middle" x="171" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">Pow</text></g><!-- Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,)&#45;&gt;Pow(Symbol(x), Integer(2))_(1, 0) --><g id="edge5" class="edge"><title>Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,)&#45;&gt;Pow(Symbol(x), Integer(2))_(1, 0)</title><path fill="none" stroke="#000000" d="M171,-143.8314C171,-136.131 171,-126.9743 171,-118.4166"/><polygon fill="#000000" stroke="#000000" points="174.5001,-118.4132 171,-108.4133 167.5001,-118.4133 174.5001,-118.4132"/></g><!-- Add(Integer(5), Symbol(x), Symbol(y))_(1, 1) --><g id="node9" class="node"><title>Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)</title><ellipse fill="none" stroke="#000000" cx="279" cy="-90" rx="27" ry="18"/><text text-anchor="middle" x="279" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">Add</text></g><!-- Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,)&#45;&gt;Add(Integer(5), Symbol(x), Symbol(y))_(1, 1) --><g id="edge6" class="edge"><title>Mul(Pow(Symbol(x), Integer(2)), Add(Integer(5), Symbol(x), Symbol(y)))_(1,)&#45;&gt;Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)</title><path fill="none" stroke="#000000" d="M190.3082,-149.1278C207.3555,-137.763 232.4019,-121.0654 251.5344,-108.3104"/><polygon fill="#000000" stroke="#000000" points="253.4799,-111.2199 259.8589,-102.7607 249.5969,-105.3956 253.4799,-111.2199"/></g><!-- Symbol(x)_(1, 0, 0) --><g id="node7" class="node"><title>Symbol(x)_(1, 0, 0)</title><ellipse fill="none" stroke="#000000" cx="99" cy="-18" rx="27" ry="18"/><text text-anchor="middle" x="99" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">x</text></g><!-- Pow(Symbol(x), Integer(2))_(1, 0)&#45;&gt;Symbol(x)_(1, 0, 0) --><g id="edge7" class="edge"><title>Pow(Symbol(x), Integer(2))_(1, 0)&#45;&gt;Symbol(x)_(1, 0, 0)</title><path fill="none" stroke="#000000" d="M155.7307,-74.7307C145.803,-64.803 132.6847,-51.6847 121.5637,-40.5637"/><polygon fill="#000000" stroke="#000000" points="123.7933,-37.8436 114.2473,-33.2473 118.8436,-42.7933 123.7933,-37.8436"/></g><!-- Integer(2)_(1, 0, 1) --><g id="node8" class="node"><title>Integer(2)_(1, 0, 1)</title><ellipse fill="none" stroke="#000000" cx="171" cy="-18" rx="27" ry="18"/><text text-anchor="middle" x="171" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">2</text></g><!-- Pow(Symbol(x), Integer(2))_(1, 0)&#45;&gt;Integer(2)_(1, 0, 1) --><g id="edge8" class="edge"><title>Pow(Symbol(x), Integer(2))_(1, 0)&#45;&gt;Integer(2)_(1, 0, 1)</title><path fill="none" stroke="#000000" d="M171,-71.8314C171,-64.131 171,-54.9743 171,-46.4166"/><polygon fill="#000000" stroke="#000000" points="174.5001,-46.4132 171,-36.4133 167.5001,-46.4133 174.5001,-46.4132"/></g><!-- Integer(5)_(1, 1, 0) --><g id="node10" class="node"><title>Integer(5)_(1, 1, 0)</title><ellipse fill="none" stroke="#000000" cx="243" cy="-18" rx="27" ry="18"/><text text-anchor="middle" x="243" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">5</text></g><!-- Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)&#45;&gt;Integer(5)_(1, 1, 0) --><g id="edge9" class="edge"><title>Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)&#45;&gt;Integer(5)_(1, 1, 0)</title><path fill="none" stroke="#000000" d="M270.2854,-72.5708C266.0403,-64.0807 260.8464,-53.6929 256.1337,-44.2674"/><polygon fill="#000000" stroke="#000000" points="259.237,-42.6477 251.6343,-35.2687 252.976,-45.7782 259.237,-42.6477"/></g><!-- Symbol(x)_(1, 1, 1) --><g id="node11" class="node"><title>Symbol(x)_(1, 1, 1)</title><ellipse fill="none" stroke="#000000" cx="315" cy="-18" rx="27" ry="18"/><text text-anchor="middle" x="315" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">x</text></g><!-- Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)&#45;&gt;Symbol(x)_(1, 1, 1) --><g id="edge10" class="edge"><title>Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)&#45;&gt;Symbol(x)_(1, 1, 1)</title><path fill="none" stroke="#000000" d="M287.7146,-72.5708C291.9597,-64.0807 297.1536,-53.6929 301.8663,-44.2674"/><polygon fill="#000000" stroke="#000000" points="305.024,-45.7782 306.3657,-35.2687 298.763,-42.6477 305.024,-45.7782"/></g><!-- Symbol(y)_(1, 1, 2) --><g id="node12" class="node"><title>Symbol(y)_(1, 1, 2)</title><ellipse fill="none" stroke="#000000" cx="387" cy="-18" rx="27" ry="18"/><text text-anchor="middle" x="387" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">y</text></g><!-- Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)&#45;&gt;Symbol(y)_(1, 1, 2) --><g id="edge11" class="edge"><title>Add(Integer(5), Symbol(x), Symbol(y))_(1, 1)&#45;&gt;Symbol(y)_(1, 1, 2)</title><path fill="none" stroke="#000000" d="M298.3082,-77.1278C315.3555,-65.763 340.4019,-49.0654 359.5344,-36.3104"/><polygon fill="#000000" stroke="#000000" points="361.4799,-39.2199 367.8589,-30.7607 357.5969,-33.3956 361.4799,-39.2199"/></g></g></svg>)
<graphviz.files.Source at 0x7fc7dc51b2e8>
<graphviz.files.Source at 0x7ff8a018e7f0>
%% Cell type:markdown id: tags:
Programatically the children node type is acessible as ``expr.func`` and its children as ``expr.args``.
With these members a tree can be traversed and modified.
%% Cell type:code id: tags:
``` python
expr.func
```
%%%% Output: execute_result
sympy.core.add.Add
%% Cell type:code id: tags:
``` python
expr.args
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALAAAAAcCAYAAADBaTXLAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAG2klEQVR4Ae2bj3HVOBDG85gUELgKLnQQoIIjHYTr4KCDZKggEzrgqIAjHQAVHKQDchUE0kHu+ymSkfRk2ZZl+5G8nVFs/dv9tFqtVvLL6ubmZqc2rVarM/HcU9pXulQ6kZxrPRejTcS0mDLukOBVbQO2hvJWfDHcHeU/6LGv/JOl9LaJmJbSxV2T+yAekCb7QOl5XD4gfxS1PVUennjjpWgTMS2li19SruznOAU8MGCMV41ey1t+SjUeUOYbqwsd/LIBrKo19eVvCqZqg7sHjC5kn+zmAe0GuZ2dd8r/EZUNysr4H0cdWBTQl9vH/H83EdP8Wvi1JeJUZcCHSi/1/rcbTeOBVfFWhe9V6byTazP2yYFu8UNcNIhBmKSbfRQX8dhmK2lAuj1Cx13sZJsnanOitntNWxXyTmde9sjXSuKHoXCgq8ZzLK+hmNCJ0sexcu9rf+nuqxKL39iWnuzIOMsjXyfKu8N+1lbUjli4sSnTWAXVDU08Ad0I8sEu9V6CSX2YAG5Rsord1qf1I939UMI5+uks1pfqcRRf4/I4rzbG2bpyF0JgbB+VqpBcPLcYjyXkFQzJK7lYuIqMoUxKMKkPevmicZgrwaEyS9pLJttp8sRdwm9snwp40N0bpXMlQgDsgmdAKiN0Jc7Njt3OxSW4YLCrF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mfBA+V6buTB4Inu/Elu/s/NFJ3fS7zKK3gL6NtQ8c+PgjBiviuERmuXuonGmfynlCCNnDkzwzoMTXfJeTiDW7upqlUkmB5bmjrAW31p8hI0bmll/yGN1UnQPnBq3+LEIs/eqqX6urDYexzf1lCxCVT7AZG2O8SgZHZn/ibMelSA/eTJW40mI1Tm3zCEDET62uyfCmLxiHMKrb1vJNOcNyeyKA9dYqm9w6re8zHWT+BV54DF41gB2FEgWV4tXwtp6A+ON6SE6IgaG3L3cbW6GvxbI1QyiikVIQYRHhE9sfbMQk0IqFHagfn7Yg0Fz91tkvGAYiQcWvcjaA1FAq/FaRvwG4tzpqPmvZDFgsO9VQcw7OUle8K8hkwssFGAV+0F6CQ6whewm7SasHNYwYqjrNwe3rTbkr7Bz5nglPQeH0Bie2hHW8YHJXAn6BszW9VkVyZN3zOg+5aU0PDDeYfCB9T7pqXSs0i+hGl+Du4zXfb1rQt3GgBEuRhyqDsVotpgPuVvaaqBLA9aJ8Cu2YCcMDBgm1oiJw4rjpi4w2/qtBoZqQHZJbL/2z8FrBjyU8bb9VgNLauB//cXFCFN3t9QAAAAASUVORK5CYII=)
$\displaystyle \left( x^{2}, \ x^{2} \left(x + y + 5\right)\right)$
⎛ 2 2 ⎞
⎝x , x ⋅(x + y + 5)⎠
%% Cell type:markdown id: tags:
## Using *pystencils*
### Fields
*pystencils* is a module to generate code for stencil operations.
One has to specify an update rule for each element of an array, with optional dependencies to neighbors.
This is done use pure *sympy* with one addition: **Fields**.
Fields represent a multidimensional array, where some dimensions are considered *spatial*, and some as *index* dimensions. Spatial coordinates are given relative (i.e. one can specify "the current cell" and "the left neighbor") whereas index dimensions are used to index multiple values per cell.
%% Cell type:code id: tags:
``` python
my_field = ps.fields("f(3) : double[2D]")
```
%% Cell type:markdown id: tags:
Neighbors are labeled according to points on a compass where the first coordinate is west/east, second coordinate north/south and third coordinate top/bottom.
%% Cell type:code id: tags:
``` python
field_access = my_field[1, 0](1)
field_access
```
%%%% Output: execute_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(1,0)}^{1}}$
f_E__1
%% Cell type:markdown id: tags:
The result of indexing a field is an instance of ``Field.Access``. This class is a subclass of a *sympy* Symbol and thus can be used whereever normal symbols can be used. It is just like a normal symbol with some additional information attached to it.
%% Cell type:code id: tags:
``` python
isinstance(field_access, sp.Symbol)
```
%%%% Output: execute_result
True
%% Cell type:markdown id: tags:
### Building our first stencil kernel
Lets start by building a simple filter kernel. We create a field representing an image, then define a edge detection filter on the third pixel component which is blue for an RGB image.
%% Cell type:code id: tags:
``` python
img_field = ps.fields("img(4): [2D]")
```
%% Cell type:code id: tags:
``` python
w1, w2 = sp.symbols("w_1 w_2")
color = 2
sobel_x = (-w2 * img_field[-1,0](color) - w1 * img_field[-1,-1](color) - w1 * img_field[-1, +1](color) \
+w2 * img_field[+1,0](color) + w1 * img_field[+1,-1](color) - w1 * img_field[+1, +1](color))**2
sobel_x
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAywAAAAsCAYAAACHZjwAAAAACXBIWXMAAA7EAAAOxAGVKw4bAAARw0lEQVR4Ae1di7HVOBbkUS8AYCIAMoCZCGbIgE8EO2TAFBFMMRkAEWxBBjARPCAD2Ah2eBmw3bo6Xln+Stfyt1Xla1ufI6lPW9K5kuyLHz9+3JATAkJACAgBISAEhIAQEAJCQAgsicDFxcUr5H8Lxz0c33D8AVvl+kIGC6CQEwJCQAgIASEgBISAEBACQmAxBLyx8hq2CQ2VG7h/h9M93D+UwbKYWpSxEBACQkAICAEhIASEgBAQAkQABspXnB4FBssD3H/Gcf8mfuSEgBAQAkJACAgBISAEhIAQEAJLI8ClYOau/cW9S/PRWQgIASEgBISAEBACQkAICAEhsAQCmFm5H+XLGRa6T5phOQGhXyEgBISAEBACQkAICAEhIATWgwA34LtN970GC9aS/c5jPeVWSYSAEBACQkAICAEhIASEgBBYKwKwHW7h4Ib5bIf0NFY+YtblLwrpXBKGiC8Q/ow78xlRTggIASEgBISAEBACQkAICAEh0IcAbIdr2BGvcX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qS8KCcvDtQs+R0dGWhgUQ6FIICAEhIASEgBAQAkJACAiBVARgQ3ApOidAuNH+LGOFebfOsLiAk1XEjLgf4uyMKFNOCAgBISAEhIAQEAJCQAgIgX0j4FdrvYMNMcme6k6DhTD6qZxbyOzLvmFV7YSAEBACQkAICAEhIASEgBA4FwE/u/Iz7Iesj0S25f8/C120EDRjZpUAAAAASUVORK5CYII=)
$\displaystyle \left(- {{img}_{(-1,-1)}^{2}} w_{1} - {{img}_{(-1,0)}^{2}} w_{2} - {{img}_{(-1,1)}^{2}} w_{1} + {{img}_{(1,-1)}^{2}} w_{1} + {{img}_{(1,0)}^{2}} w_{2} - {{img}_{(1,1)}^{2}} w_{1}\right)^{2}$
(-img_SW__2⋅w₁ - img_W__2⋅w₂ - img_NW__2⋅w₁ + img_SE__2⋅w₁ + img_E__2⋅w₂ - img
2
_NE__2⋅w₁)
%% Cell type:markdown id: tags:
We have mixed some standard *sympy* symbols into this expression to possibly give the different directions different weights. The complete expression is still a valid *sympy* expression, so all features of *sympy* work on it. Lets for example now fix one weight by substituting it with a constant.
%% Cell type:code id: tags:
``` python
sobel_x = sobel_x.subs(w1, 0.5)
sobel_x
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAzUAAAAsCAYAAABc3ZYiAAAACXBIWXMAAA7EAAAOxAGVKw4bAAATH0lEQVR4Ae2djbXUthaFgUUBF1JBoAOSVJDQAUkqSOiALCrIIh0QKniLdJCkAgIdkFfBg9sBb3++ktF4/CePPLbHW2t5LOvnSN5nW9KxZM3tT58+3bIzAkbACBgBI2AEjIARMAJGwAisHYHbt2+/UB2vdDzQ8a+OX2TPXN+2USMo7IyAETACRsAIGAEjYASMgBFYNQLBoHkp+wVj5pauX+v0QNdf2ahZtepcOSNgBIyAETACRsAIGAEjYARAQEbMe50eJ0bNI12/1fHwjn7sjIARMAJGwAgYASNgBIyAETACW0CAZWfRXQfPg7sxxGcjYASMgBEwAkbACBgBI2AEjMBaEdA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nZfmn9uN9ZOpiyMjdOe+ZUH1ltSbZLmfWFCXSxddkksj2o14uzljDiZYmn8AHuX0nm/r5qoEqhgNFn9UyBv+vqVUvQId2Y6A8MXwYDvps2Cr8vgT0NnLUjnsmgdZ7QICW9C19Xa5dDX/Lle3pe7sFI4or/uWUorIlHNuvak89++ZOtpK8jVzSXXDFvlpyhi2NmpQRLjJHz1InYeWwvdPYYsFOqtTOSw5mmTl5lQslHNf9+Qliw3g1qxr662hrAu8NP8uUKmFb2kKR0Lb4b6lsC5yxJ1Lb0HX7t9zlLOxtGvkkurEBMBzjSsnfaObLj9j6QxTkixp4gMdu/IIsCSo+lPQ8qIPJNIQsf52Nqf7YGaPpU02aNpRXqWurbd2ZV1gqPl3gUotfEtTOOK+pbASJoibXW/uJyZoZZtZ1sil54JyzK7ArYgfzNSQIgy6n2qw6iVFrZCdFih8zzKLcloth3PrPrCm2cb6ejj1PlOsUdfW2364aP7tR9dT79QcmYrcsvnm1pv7iWX1e87S18SlwLuTVosdGTWAKcF8+M1SKWZu7IyAETACRsAIGAEjYASMgBEwAsURkN3B7mhvdXwl22PySqOD5WdJLdkt6akK8TK0BBR7jYARMAJGwAgYASNgBIyAESiDgGwNPmdgMoXNASYbNNSmdaamirixmiiE7yZOKgR5dkbACBgBI2AEjIARMAJGwAgYgYhAWB32WrbGyd9odxo1FBamg65U0LtYuM9GwAgYASNgBIyAETACRsAIGIFTEAizNF/Lzsj+o822cv8PY4mfAbzaDhoAAAAASUVORK5CYII=)
$\displaystyle \left(- 0.5 {{img}_{(-1,-1)}^{2}} - {{img}_{(-1,0)}^{2}} w_{2} - 0.5 {{img}_{(-1,1)}^{2}} + 0.5 {{img}_{(1,-1)}^{2}} + {{img}_{(1,0)}^{2}} w_{2} - 0.5 {{img}_{(1,1)}^{2}}\right)^{2}$
(-0.5⋅img_SW__2 - img_W__2⋅w₂ - 0.5⋅img_NW__2 + 0.5⋅img_SE__2 + img_E__2⋅w₂ -
2
0.5⋅img_NE__2)
%% Cell type:markdown id: tags:
Now lets built an executable kernel out of it, which writes the result to a second field. Assignments are created using *pystencils* `Assignment` class, that gets the left- and right hand side of the assignment.
%% Cell type:code id: tags:
``` python
dst_field = ps.fields('dst: [2D]' )
update_rule = ps.Assignment(dst_field[0,0], sobel_x)
update_rule
```
%%%% Output: execute_result
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA5gAAAAsCAYAAAAAexdDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAXUklEQVR4Ae2dj9XUNtbGFw4FvLAVBDpgkwo26YAkFSR0wB4qyCEdkFSwSzpItgICHZCt4EveDvien1/JyB6PLXnssTzz6ByP9ffq6rlXsq6lke99/Pjxb3ZGwAgYASNgBIyAETACRsAIGAEjYARyEbh3794r5b3R9VjXH7r+Jdvy9p4NTEFhZwSMgBEwAkbACBgBI2AEjIARMAJZCATj8rVsSQzLvyn8RrfHCv/DBmYWhM5kBIyAETACRsAIGAEjYASMgBEwAiAgg/KDbl8lBuZThd/penJfP3ZGwAgYASNgBIyAETACRsAIGAEjYARKEGBrbHS3wfP4QYzx3QgYASNgBIyAETACRsAIGAEjYASMwBQCWrl80svDCibud69g3gHhXyNgBIyAETACRsAIGAEjYASMgBGYhwAH/jSH/NjAnAfg2Utpn/P3XGev2BUaASNgBIyAETACRsAIGAEjcJEIyL640cUBPbOdymNc/qZVzR8h4i2ys6E8X0EJ7YVq+5ZTmc5Xq2syAkbACBgBI2AEjIARMAJG4JIRkH1xK1vjta53c2wNlWMB7EZln0ecfIpsRKLSu4T2pVjjrcJnKEClbJotI2AEjIARMAJGwAgYASNgBHaKgGwOFrS+kL3xdW4Tgp3CSbL/okwI/2kDMxfBDfJJSHy49H+6/inBvd+ABVdpBIyAETACRsAIGAEjYASMwBUgINuDz4zwbcufppqrvBzq87OuH5K8rGJ+bQMzQaQ2rwTX7IcueZNQWxvMjxEwAkbACBgBI2AEjIARMAL1IyDbg8+OYGRO7pxU3r+Uj8WwjpPdcs8GZgeSegLhrUDz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IjkNfbsfy1ZYW+P7WBsM6khG+vwpb3s6s6tbW78h8qOeR2pT98iWWvfR7zbK23C5d+5pnXLVjjfWvDv2bM0YF2a02d4rIWEciEt37uWRm/Lu4X2qoNn0SPyzEvNSccvZ5DpttkY1KIuY5JXbW8mukMXYX7R917cq4pD3wrRvbLvmDrd3yCLBtke/7rO0w+lbTb5hXO1jxZvuljcthaVYpa8ttWFgXGGv9u0ChLtykOTriZ8vCQigkt7rM/IwolMi+s9emTy8FZ86XFY6ivvkK5lHOnIDhgAH0XIaDtz2uoA/Cd9XV8xVYHiSpdvCmaXer9IONWSmyRllbbisJu0Ky1r8KhVIZS9aRygSSwc7aMvMzIkMIF5SlFn0KenfyDkobmJUrpwTNoS1ssTp6um7lTTB7RsAIGAEjYASMgBEwAkbACFSMgGwOTph9p+sfp+6+23yLbMU418Iap04+l9C9VbYWiZgPI2AEjIARMAJGwAgYASNwIQjIzuDvVixqcbDPyX/t8grmDhQjvFFA6PzP7mSh76DJZtEIGAEjYASMgBEwAkbACBiBMyAgWwM7443sjEXO87CBeQahLVFFMDJvJPiib4AuUbdpGAEjYASMgBEwAkbACBgBI3B5CITVy89lY/y2VOv+H84LF1TGgi7oAAAAAElFTkSuQmCC)
$\displaystyle {{dst}_{(0,0)}} \leftarrow \left(- 0.5 {{img}_{(-1,-1)}^{2}} - {{img}_{(-1,0)}^{2}} w_{2} - 0.5 {{img}_{(-1,1)}^{2}} + 0.5 {{img}_{(1,-1)}^{2}} + {{img}_{(1,0)}^{2}} w_{2} - 0.5 {{img}_{(1,1)}^{2}}\right)^{2}$
dst_C := (-0.5⋅img_SW__2 - img_W__2⋅w₂ - 0.5⋅img_NW__2 + 0.5⋅img_SE__2 + img_E
2
__2⋅w₂ - 0.5⋅img_NE__2)
%% Cell type:markdown id: tags:
Next we can see *pystencils* in action which creates a kernel for us.
%% Cell type:code id: tags:
``` python
from pystencils import create_kernel
ast = create_kernel(update_rule, cpu_openmp=False)
compiled_kernel = ast.compile()
```
%% Cell type:markdown id: tags:
This compiled kernel is now just an ordinary Python function.
Now lets grab an image to apply this filter to:
%% Cell type:code id: tags:
``` python
import requests
import imageio
from io import BytesIO
response = requests.get("https://www.python.org/static/img/python-logo.png")
img = imageio.imread(BytesIO(response.content)).astype(np.double)
img /= img.max()
plt.imshow(img);
```
%%%% Output: display_data
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA6IAAAEfCAYAAABbM3sFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XuQXOd53/nfMxcMMAAG1wEwuAMkeLUjUoJlyVI5tGnZkrwVOlkrKznJcr3ccLdKduxNaiPZla1VqnZr5Yod7aUSVTGRYu6WI0uWraXWKztSKDEXK6IIirQoihdAIAgMrgNwMAAGwFzf/QPN9zzd6LfnnOnuMz09308VCk/3vKfP22dO98yZ/p3nWAhBAAAAAACUpWepJwAAAAAAWFk4EAUAAAAAlIoDUQAAAABAqTgQBQAAAACUigNRAAAAAECpOBAFAAAAAJSKA1EAAAAAQKmaOhA1sw+a2WtmdszMPtmqSQEAAAAAupeFEBa3oFmvpNclfUDSqKTnJH0shPDD1k0PAAAAANBt+ppY9t2SjoUQjkuSmf2hpEckJQ9Et27dGvbv39/EKgEAAAAAner555+/GEIYXmhcMweiuySdcrdHJf1kowX279+vI0eONLFKAAAAAECnMrM384xr5hxRq3PfbTlfM3vczI6Y2ZGxsbEmVgcAAAAA6AbNHIiOStrjbu+WdKZ2UAjhiRDC4RDC4eHhBT+hBQAAAAB0uWYORJ+TdMjMDpjZKkkflfTV1kwLAAAAANCtFn2OaAhh1sx+TdK/kdQr6fMhhJdbNjMAAAAAQFdqplmRQghfk/S1Fs0FAAAAALACNBPNBQAAAACgMA5EAQAAAACl4kAUAAAAAFAqDkQBAAAAAKXi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zeros_like(img[..., 0])
# here we call the compiled stencil function
compiled_kernel(img=img, dst=filtered_image, w_2=0.5)
plt.imshow(filtered_image, cmap='gray');
```
%%%% Output: display_data
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA6IAAAEfCAYAAABbM3sFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XmwXNV99vtnGSSEBjRLgASSAFlICCSMwAwGZGMIIkwpm1vYlF8FE/PGBYkdXLn2+1Y5JpWkyqlKXl/fVEKCY25IxY5tYjPYxmYQyAwGrNlCsxiE5gnNQgKRdf/QYenpdu9zdp/u3qe7z/dT5eJ3Wt29V+9ee3dv97N/O8QYBQAAAABAUT7U0wMAAAAAAPQuHIgCAAAAAArFgSgAAAAAoFAciAIAAAAACsWBKAAAAACgUByIAgAAAAAKxYEoAAAAAKBQNR2IhhCuDSGsCiGsDSF8rV6DAgAAAAC0rxBj7N4DQzhO0mpJV0vaIGmepM/EGJfXb3gAAAAAgHZzfA2PvUjS2hjj65IUQviBpJskZR6IhhC6d9QLAAAAAGgFO2KMI7u6Uy3R3DGS1tvfGzpuAwAAAAD0Tuvy3KmWX0RDhdt+5xfPEMKdku6sYTkAAAAAgDZSy4HoBkmn2d9jJW0qv1OM8X5J90ul0dyZM2fWsGgAAAAAQDOYO3du1Y+pJZo7T9LEEMKEEEJfSbdKeqyG5wMAAAAA9ALd/kU0xngkhHC3pCckHSfpgRjjsrqNDAAAAADQlmqJ5irG+Likx+s0FgAAAABAL1BLNBcAAAAAgKpxIAoAAAAAKBQHogAAAACAQnEgCgAAAAAoFAeiAAAAAIBCcSAKAAAAACgUB6IAAAAAgEJxIAoAAAAAKBQHogAAAACAQnEgCgAAAAAoFAeiAAAAAIBCcSAKAAAAACgUB6IAAAAAgEJxIA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c8duaRSV83Re7bO+NRnY997GOp9tfm27XH5fx98E7LPjc6e50ee/bHe9zVY7Ae3fZunFlz0d93f3+GDx+e6vL4n//t792MGccSTL59+ZxzHs31eGfWWD2G6cst/7es/apvm77N+j7P30ePQHp02KOU/jqdr1epNIrp77e/X1//+tcrLqNe3XTLx+r7PY8q+3cKXx8eLff31CO4vj/yeendY33f6d39N2zYUDI+j6l6fNqX5+/77t27U/3lL3851R6bryWm6/NKkqZPn55qj17752NWxH3kyJGp9jnqc9873fqpNP79wLcbqbTrs39ueO1z08ft69hjuh6Rztr/la8boFURzQUAAAAAND0ORAEAAAAAhWq7aK5fIDwrduuxHY/2eWQlK6KapTuR2HpFWWvpXFvrOBrxGjqTFc3N0/E0z/K609U4K6oza9asVHsEaMGCBVUvoxls2rQp1R/96EdTvWjRolT7e1J+QXtfBx738jjVXXfdlWqPHnqX3fLnrcS3R4/1le93fK6sXr264nP5hd69I6nHLz1SW969sivPPfdcqi+99NKSf/N1kxVl9Xiex0+bhUd1Lr744lRnRUh9P1zra/O4nPOYqX82eITP17e/p76v8e6s3vnT9y+//vWvS5bt751HAbM6fw8bNqzi7dVGc7PmTPk4spbtp6v4duAd6b0TqHcs9vpTn/pUqn0+PPTQQ5nj8XXun/G+7/W4pr+P1W6PLusUBKl0Hfp3Df8M8XXmz/WRj3wk1X5KgD9n1n4ua9925ZVXltzP921ZXYR9DjmPlnqn66yOzFn88+Ciiy4q+TffL3hHXH/dZ5xxRqr9dZ933nmp9jngn1F5PifK+TJ8TJMmTUq1rxu/T1a3b+9S7O/DV77ylYrL9VM1gFZDNBcAAAAA0PQ4EAUAAAAAFKryFZNbzMqVK1Pt3RC9i6FHZ7yDn0ciPK6VJyraLHHcei23Ho+p5rFFd/WsNo6bd3we1fEuf48++miqv/SlL6Xao2yPPPJIrmU0A+9O6BEjj595PG7EiBElj/fHXH/99an29f/AAw+k2mOVHmvz6KE/1t8vv927dz755JMlY7rppptS7V0tfay+v/AonHce9deaFVvOozxWmSdm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y3CTpBzHGwzHGNySt1dHPVyBTjHFzjHFhR71P0gpJY8T+DHXUyTzLwv6slyvyQHSMpPX29wZ1PjmBakRJT4YQFoQQ7uy4bXSMcbN0dOcoaVSPjQ7tJGtesY9Dvd3dEYt8wE4tYJ6hJiGE8ZLOl/SK2J+hQcrmmcT+DBUUeSAaKtxGy17Uy2Uxxo/oaJzorhDCFT09IPQ67ONQT/dJOlPSdEmbJf19x+3MM3RbCGGgpB9L+nKMcW9nd61wG/MMuVSYZ+zPUFGRB6IbJJ1mf4+VtKnA5aONxRg3dfx3m6SHdTTasfWDKFHHf7f13AjRRrLmFfs41E2McWuM8f0Y439L+o6OxdWYZ+iWEEIfHT04+F6M8ScdN7M/Q11Vmmfsz5ClyAPReZImhhAmhBD66ujJyY8VuHy0qRDCgBDCoA9qSddIelVH59fsjrvNlvRoz4wQbSZrXj0m6X90dJu8WNKeDyJvQLXKzsf7Ax3dp0lH59mtIYQTQggTdLSZzG+KHh9aSwghSPqupBUxxv9j/8T+DHWTNc/YnyHL8UUtKMZ4JIRwt6QnJB0n6YEY47Kilo+2NlrSw0f3fzpe0vdjjL8MIcyT9KMQwh2S3pJ0Sw+OES0ohPCfkmZKGhFC2CDpG5K+qcrz6nFJ1+los4WDkm4vfMBoSRnzbGYIYbqOxtTelPQ/JSnGuCyE8CNJy3W0Q+VdMcb3e2LcaCmXSfqcpKUhhMUdt/1vsT9DfWXNs8+wP0MlIUai2AAAAACA4hQZzQUAAAAAgANRAAAAAECxOBAFAAAAABSKA1EAAAAAQKE4EAUAAAAAFIoDUQAAAABAoTgQBQAAAAAUigNRAAAAAECh/n+xbZDBgJeQ/gAAAABJRU5ErkJggg==)
%% Cell type:markdown id: tags:
### Digging into *pystencils*
On our way we have created an ``ast``-object. We can inspect this, to see what *pystencils* actually does.
%% Cell type:code id: tags:
``` python
ps.to_dot(ast, graph_style={'size': "9.5,12.5"})
```
%%%% Output: execute_result
![](data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!-- Generated by graphviz version 2.40.1 (20161225.0304)--><!-- Title: %3 Pages: 1 --><svg width="684pt" height="468pt"viewBox="0.00 0.00 684.00 467.74" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="graph0" class="graph" transform="scale(.9826 .9826) rotate(0) translate(4 472)"><title>%3</title><polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-472 692.083,-472 692.083,4 -4,4"/><!-- 140495254316984 --><g id="node1" class="node"><title>140495254316984</title><ellipse fill="#a056db" stroke="#000000" cx="219.8449" cy="-450" rx="107.781" ry="18"/><text text-anchor="middle" x="219.8449" y="-446.3" font-family="Times,serif" font-size="14.00" fill="#000000">Func: kernel (dst,img,w_2)</text></g><!-- 140495254318440 --><g id="node11" class="node"><title>140495254318440</title><ellipse fill="#dbc256" stroke="#000000" cx="219.8449" cy="-378" rx="31.6951" ry="18"/><text text-anchor="middle" x="219.8449" y="-374.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140495254316984&#45;&gt;140495254318440 --><g id="edge10" class="edge"><title>140495254316984&#45;&gt;140495254318440</title><path fill="none" stroke="#000000" d="M219.8449,-431.8314C219.8449,-424.131 219.8449,-414.9743 219.8449,-406.4166"/><polygon fill="#000000" stroke="#000000" points="223.345,-406.4132 219.8449,-396.4133 216.345,-406.4133 223.345,-406.4132"/></g><!-- 140495254317656 --><g id="node2" class="node"><title>140495254317656</title><ellipse fill="#56db7f" stroke="#000000" cx="144.8449" cy="-306" rx="61.99" ry="18"/><text text-anchor="middle" x="144.8449" y="-302.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_img_22</text></g><!-- 140495254316256 --><g id="node3" class="node"><title>140495254316256</title><ellipse fill="#3498db" stroke="#000000" cx="295.8449" cy="-306" rx="70.6878" ry="18"/><text text-anchor="middle" x="295.8449" y="-302.3" font-family="Times,serif" font-size="14.00" fill="#000000">Loop over dim 0</text></g><!-- 140495254316032 --><g id="node10" class="node"><title>140495254316032</title><ellipse fill="#dbc256" stroke="#000000" cx="295.8449" cy="-234" rx="31.6951" ry="18"/><text text-anchor="middle" x="295.8449" y="-230.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140495254316256&#45;&gt;140495254316032 --><g id="edge7" class="edge"><title>140495254316256&#45;&gt;140495254316032</title><path fill="none" stroke="#000000" d="M295.8449,-287.8314C295.8449,-280.131 295.8449,-270.9743 295.8449,-262.4166"/><polygon fill="#000000" stroke="#000000" points="299.345,-262.4132 295.8449,-252.4133 292.345,-262.4133 299.345,-262.4132"/></g><!-- 140495254318496 --><g id="node4" class="node"><title>140495254318496</title><ellipse fill="#56db7f" stroke="#000000" cx="57.8449" cy="-162" rx="57.6901" ry="18"/><text text-anchor="middle" x="57.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00</text></g><!-- 140495254316592 --><g id="node5" class="node"><title>140495254316592</title><ellipse fill="#56db7f" stroke="#000000" cx="208.8449" cy="-162" rx="74.9875" ry="18"/><text text-anchor="middle" x="208.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_img_22_01</text></g><!-- 140495254317320 --><g id="node6" class="node"><title>140495254317320</title><ellipse fill="#56db7f" stroke="#000000" cx="383.8449" cy="-162" rx="81.7856" ry="18"/><text text-anchor="middle" x="383.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_img_22_0m1</text></g><!-- 140495254318664 --><g id="node7" class="node"><title>140495254318664</title><ellipse fill="#3498db" stroke="#000000" cx="554.8449" cy="-162" rx="70.6878" ry="18"/><text text-anchor="middle" x="554.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">Loop over dim 1</text></g><!-- 140495254318776 --><g id="node9" class="node"><title>140495254318776</title><ellipse fill="#dbc256" stroke="#000000" cx="554.8449" cy="-90" rx="31.6951" ry="18"/><text text-anchor="middle" x="554.8449" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140495254318664&#45;&gt;140495254318776 --><g id="edge2" class="edge"><title>140495254318664&#45;&gt;140495254318776</title><path fill="none" stroke="#000000" d="M554.8449,-143.8314C554.8449,-136.131 554.8449,-126.9743 554.8449,-118.4166"/><polygon fill="#000000" stroke="#000000" points="558.345,-118.4132 554.8449,-108.4133 551.345,-118.4133 558.345,-118.4132"/></g><!-- 140495254317040 --><g id="node8" class="node"><title>140495254317040</title><ellipse fill="#56db7f" stroke="#000000" cx="554.8449" cy="-18" rx="133.4768" ry="18"/><text text-anchor="middle" x="554.8449" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00[_stride_dst_1*ctr_1]</text></g><!-- 140495254318776&#45;&gt;140495254317040 --><g id="edge1" class="edge"><title>140495254318776&#45;&gt;140495254317040</title><path fill="none" stroke="#000000" d="M554.8449,-71.8314C554.8449,-64.131 554.8449,-54.9743 554.8449,-46.4166"/><polygon fill="#000000" stroke="#000000" points="558.345,-46.4132 554.8449,-36.4133 551.345,-46.4133 558.345,-46.4132"/></g><!-- 140495254316032&#45;&gt;140495254318496 --><g id="edge3" class="edge"><title>140495254316032&#45;&gt;140495254318496</title><path fill="none" stroke="#000000" d="M267.6085,-225.4579C228.6723,-213.6789 157.8187,-192.2442 109.3243,-177.5736"/><polygon fill="#000000" stroke="#000000" points="110.2227,-174.1888 99.6376,-174.6432 108.1957,-180.8889 110.2227,-174.1888"/></g><!-- 140495254316032&#45;&gt;140495254316592 --><g id="edge4" class="edge"><title>140495254316032&#45;&gt;140495254316592</title><path fill="none" stroke="#000000" d="M277.8184,-219.0816C266.2777,-209.5306 251.0436,-196.9231 237.8284,-185.9864"/><polygon fill="#000000" stroke="#000000" points="239.8475,-183.1143 229.9121,-179.4349 235.3845,-188.507 239.8475,-183.1143"/></g><!-- 140495254316032&#45;&gt;140495254317320 --><g id="edge5" class="edge"><title>140495254316032&#45;&gt;140495254317320</title><path fill="none" stroke="#000000" d="M314.0785,-219.0816C325.7519,-209.5306 341.1611,-196.9231 354.5282,-185.9864"/><polygon fill="#000000" stroke="#000000" points="357.0123,-188.4762 362.5355,-179.4349 352.5796,-183.0585 357.0123,-188.4762"/></g><!-- 140495254316032&#45;&gt;140495254318664 --><g id="edge6" class="edge"><title>140495254316032&#45;&gt;140495254318664</title><path fill="none" stroke="#000000" d="M324.552,-226.0196C365.9645,-214.5073 443.366,-192.9903 496.9349,-178.0985"/><polygon fill="#000000" stroke="#000000" points="497.9488,-181.4495 506.646,-175.3989 496.0739,-174.7052 497.9488,-181.4495"/></g><!-- 140495254318440&#45;&gt;140495254317656 --><g id="edge8" class="edge"><title>140495254318440&#45;&gt;140495254317656</title><path fill="none" stroke="#000000" d="M203.571,-362.3771C193.8398,-353.0351 181.2651,-340.9635 170.2498,-330.3888"/><polygon fill="#000000" stroke="#000000" points="172.5648,-327.7594 162.9271,-323.3589 167.7171,-332.8091 172.5648,-327.7594"/></g><!-- 140495254318440&#45;&gt;140495254316256 --><g id="edge9" class="edge"><title>140495254318440&#45;&gt;140495254316256</title><path fill="none" stroke="#000000" d="M236.3357,-362.3771C246.1257,-353.1023 258.7558,-341.137 269.86,-330.6172"/><polygon fill="#000000" stroke="#000000" points="272.3977,-333.0344 277.2501,-323.6161 267.5835,-327.9527 272.3977,-333.0344"/></g></g></svg>)
<graphviz.files.Source at 0x7fc798393fd0>
![](data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!-- Generated by graphviz version 2.40.1 (20161225.0304)--><!-- Title: %3 Pages: 1 --><svg width="684pt" height="468pt"viewBox="0.00 0.00 684.00 467.74" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="graph0" class="graph" transform="scale(.9826 .9826) rotate(0) translate(4 472)"><title>%3</title><polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-472 692.083,-472 692.083,4 -4,4"/><!-- 140704680405368 --><g id="node1" class="node"><title>140704680405368</title><ellipse fill="#a056db" stroke="#000000" cx="219.8449" cy="-450" rx="107.781" ry="18"/><text text-anchor="middle" x="219.8449" y="-446.3" font-family="Times,serif" font-size="14.00" fill="#000000">Func: kernel (dst,img,w_2)</text></g><!-- 140704680405256 --><g id="node11" class="node"><title>140704680405256</title><ellipse fill="#dbc256" stroke="#000000" cx="219.8449" cy="-378" rx="31.6951" ry="18"/><text text-anchor="middle" x="219.8449" y="-374.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140704680405368&#45;&gt;140704680405256 --><g id="edge10" class="edge"><title>140704680405368&#45;&gt;140704680405256</title><path fill="none" stroke="#000000" d="M219.8449,-431.8314C219.8449,-424.131 219.8449,-414.9743 219.8449,-406.4166"/><polygon fill="#000000" stroke="#000000" points="223.345,-406.4132 219.8449,-396.4133 216.345,-406.4133 223.345,-406.4132"/></g><!-- 140704680405032 --><g id="node2" class="node"><title>140704680405032</title><ellipse fill="#56db7f" stroke="#000000" cx="144.8449" cy="-306" rx="61.99" ry="18"/><text text-anchor="middle" x="144.8449" y="-302.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_img_22</text></g><!-- 140704680404416 --><g id="node3" class="node"><title>140704680404416</title><ellipse fill="#3498db" stroke="#000000" cx="295.8449" cy="-306" rx="70.6878" ry="18"/><text text-anchor="middle" x="295.8449" y="-302.3" font-family="Times,serif" font-size="14.00" fill="#000000">Loop over dim 0</text></g><!-- 140704680404080 --><g id="node10" class="node"><title>140704680404080</title><ellipse fill="#dbc256" stroke="#000000" cx="295.8449" cy="-234" rx="31.6951" ry="18"/><text text-anchor="middle" x="295.8449" y="-230.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140704680404416&#45;&gt;140704680404080 --><g id="edge7" class="edge"><title>140704680404416&#45;&gt;140704680404080</title><path fill="none" stroke="#000000" d="M295.8449,-287.8314C295.8449,-280.131 295.8449,-270.9743 295.8449,-262.4166"/><polygon fill="#000000" stroke="#000000" points="299.345,-262.4132 295.8449,-252.4133 292.345,-262.4133 299.345,-262.4132"/></g><!-- 140704681164528 --><g id="node4" class="node"><title>140704681164528</title><ellipse fill="#56db7f" stroke="#000000" cx="57.8449" cy="-162" rx="57.6901" ry="18"/><text text-anchor="middle" x="57.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00</text></g><!-- 140704680403520 --><g id="node5" class="node"><title>140704680403520</title><ellipse fill="#56db7f" stroke="#000000" cx="208.8449" cy="-162" rx="74.9875" ry="18"/><text text-anchor="middle" x="208.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_img_22_01</text></g><!-- 140704680403352 --><g id="node6" class="node"><title>140704680403352</title><ellipse fill="#56db7f" stroke="#000000" cx="383.8449" cy="-162" rx="81.7856" ry="18"/><text text-anchor="middle" x="383.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_img_22_0m1</text></g><!-- 140704680404024 --><g id="node7" class="node"><title>140704680404024</title><ellipse fill="#3498db" stroke="#000000" cx="554.8449" cy="-162" rx="70.6878" ry="18"/><text text-anchor="middle" x="554.8449" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">Loop over dim 1</text></g><!-- 140704680404360 --><g id="node9" class="node"><title>140704680404360</title><ellipse fill="#dbc256" stroke="#000000" cx="554.8449" cy="-90" rx="31.6951" ry="18"/><text text-anchor="middle" x="554.8449" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140704680404024&#45;&gt;140704680404360 --><g id="edge2" class="edge"><title>140704680404024&#45;&gt;140704680404360</title><path fill="none" stroke="#000000" d="M554.8449,-143.8314C554.8449,-136.131 554.8449,-126.9743 554.8449,-118.4166"/><polygon fill="#000000" stroke="#000000" points="558.345,-118.4132 554.8449,-108.4133 551.345,-118.4133 558.345,-118.4132"/></g><!-- 140704680403968 --><g id="node8" class="node"><title>140704680403968</title><ellipse fill="#56db7f" stroke="#000000" cx="554.8449" cy="-18" rx="133.4768" ry="18"/><text text-anchor="middle" x="554.8449" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00[_stride_dst_1*ctr_1]</text></g><!-- 140704680404360&#45;&gt;140704680403968 --><g id="edge1" class="edge"><title>140704680404360&#45;&gt;140704680403968</title><path fill="none" stroke="#000000" d="M554.8449,-71.8314C554.8449,-64.131 554.8449,-54.9743 554.8449,-46.4166"/><polygon fill="#000000" stroke="#000000" points="558.345,-46.4132 554.8449,-36.4133 551.345,-46.4133 558.345,-46.4132"/></g><!-- 140704680404080&#45;&gt;140704681164528 --><g id="edge3" class="edge"><title>140704680404080&#45;&gt;140704681164528</title><path fill="none" stroke="#000000" d="M267.6085,-225.4579C228.6723,-213.6789 157.8187,-192.2442 109.3243,-177.5736"/><polygon fill="#000000" stroke="#000000" points="110.2227,-174.1888 99.6376,-174.6432 108.1957,-180.8889 110.2227,-174.1888"/></g><!-- 140704680404080&#45;&gt;140704680403520 --><g id="edge4" class="edge"><title>140704680404080&#45;&gt;140704680403520</title><path fill="none" stroke="#000000" d="M277.8184,-219.0816C266.2777,-209.5306 251.0436,-196.9231 237.8284,-185.9864"/><polygon fill="#000000" stroke="#000000" points="239.8475,-183.1143 229.9121,-179.4349 235.3845,-188.507 239.8475,-183.1143"/></g><!-- 140704680404080&#45;&gt;140704680403352 --><g id="edge5" class="edge"><title>140704680404080&#45;&gt;140704680403352</title><path fill="none" stroke="#000000" d="M314.0785,-219.0816C325.7519,-209.5306 341.1611,-196.9231 354.5282,-185.9864"/><polygon fill="#000000" stroke="#000000" points="357.0123,-188.4762 362.5355,-179.4349 352.5796,-183.0585 357.0123,-188.4762"/></g><!-- 140704680404080&#45;&gt;140704680404024 --><g id="edge6" class="edge"><title>140704680404080&#45;&gt;140704680404024</title><path fill="none" stroke="#000000" d="M324.552,-226.0196C365.9645,-214.5073 443.366,-192.9903 496.9349,-178.0985"/><polygon fill="#000000" stroke="#000000" points="497.9488,-181.4495 506.646,-175.3989 496.0739,-174.7052 497.9488,-181.4495"/></g><!-- 140704680405256&#45;&gt;140704680405032 --><g id="edge8" class="edge"><title>140704680405256&#45;&gt;140704680405032</title><path fill="none" stroke="#000000" d="M203.571,-362.3771C193.8398,-353.0351 181.2651,-340.9635 170.2498,-330.3888"/><polygon fill="#000000" stroke="#000000" points="172.5648,-327.7594 162.9271,-323.3589 167.7171,-332.8091 172.5648,-327.7594"/></g><!-- 140704680405256&#45;&gt;140704680404416 --><g id="edge9" class="edge"><title>140704680405256&#45;&gt;140704680404416</title><path fill="none" stroke="#000000" d="M236.3357,-362.3771C246.1257,-353.1023 258.7558,-341.137 269.86,-330.6172"/><polygon fill="#000000" stroke="#000000" points="272.3977,-333.0344 277.2501,-323.6161 267.5835,-327.9527 272.3977,-333.0344"/></g></g></svg>)
<graphviz.files.Source at 0x7ff84a432e10>
%% Cell type:markdown id: tags:
*pystencils* also builds a tree structure of the program, where each `Assignment` node internally again has a *sympy* AST which is not printed here. Out of this representation *C* code can be generated:
%% Cell type:code id: tags:
``` python
ps.show_code(ast)
```
%%%% Output: display_data
%%%% Output: execute_result
FUNC_PREFIX void kernel(double * RESTRICT _data_dst, double * RESTRICT const _data_img, int64_t const _size_dst_0, int64_t const _size_dst_1, int64_t const _stride_dst_0, int64_t const _stride_dst_1, int64_t const _stride_img_0, int64_t const _stride_img_1, int64_t const _stride_img_2, double w_2)
{
double * RESTRICT const _data_img_22 = _data_img + 2*_stride_img_2;
for (int ctr_0 = 1; ctr_0 < _size_dst_0 - 1; ctr_0 += 1)
{
double * RESTRICT _data_dst_00 = _data_dst + _stride_dst_0*ctr_0;
double * RESTRICT const _data_img_22_01 = _stride_img_0*ctr_0 + _stride_img_0 + _data_img_22;
double * RESTRICT const _data_img_22_0m1 = _stride_img_0*ctr_0 - _stride_img_0 + _data_img_22;
for (int ctr_1 = 1; ctr_1 < _size_dst_1 - 1; ctr_1 += 1)
{
_data_dst_00[_stride_dst_1*ctr_1] = ((w_2*_data_img_22_01[_stride_img_1*ctr_1] - w_2*_data_img_22_0m1[_stride_img_1*ctr_1] - 0.5*_data_img_22_01[_stride_img_1*ctr_1 + _stride_img_1] - 0.5*_data_img_22_0m1[_stride_img_1*ctr_1 + _stride_img_1] - 0.5*_data_img_22_0m1[_stride_img_1*ctr_1 - _stride_img_1] + 0.5*_data_img_22_01[_stride_img_1*ctr_1 - _stride_img_1])*(w_2*_data_img_22_01[_stride_img_1*ctr_1] - w_2*_data_img_22_0m1[_stride_img_1*ctr_1] - 0.5*_data_img_22_01[_stride_img_1*ctr_1 + _stride_img_1] - 0.5*_data_img_22_0m1[_stride_img_1*ctr_1 + _stride_img_1] - 0.5*_data_img_22_0m1[_stride_img_1*ctr_1 - _stride_img_1] + 0.5*_data_img_22_01[_stride_img_1*ctr_1 - _stride_img_1]));
}
}
}
%% Cell type:markdown id: tags:
Behind the scenes this code is compiled into a shared library and made available as a Python function. Before compiling this function we can modify the AST object, for example to parallelize it with OpenMP.
%% Cell type:code id: tags: