Note
Go to the end to download the full example code.
Describe#
This example focuses on the usage of the pylops.utils.describe.describe
method, which allows expressing any PyLops operator into its equivalent
mathematical representation. This is done with the aid of
sympy, a Python library for symbolic computing
Let’s start by defining 3 PyLops operators. Note that once an operator is defined we can attach a name to the operator; by doing so, this name will be used in the mathematical description of the operator. Alternatively, the describe method will randomly choose a name for us.
A
where: {'A': 'MatrixMult'}
A.T
where: {'A': 'MatrixMult'}
Adjoint(A)
where: {'A': 'MatrixMult'}
3*A
where: {'A': 'MatrixMult'}
A + M
where: {'A': 'MatrixMult', 'M': 'MatrixMult'}
So far so good. Let’s see what happens if we accidentally call two different operators with the same name. You will see that PyLops catches that and changes the name for us (and provides us with a nice warning!)
A*C
where: {'A': 'MatrixMult', 'C': 'Diagonal'}
We can move now to something more complicated using various composition operators
Matrix([[A*C, M*C]])
where: {'A': 'MatrixMult', 'C': 'Diagonal', 'M': 'MatrixMult'}
B
where: {'B': 'Block'}
Finally, note that you can get the best out of the describe method if working inside a Jupyter notebook. There, the mathematical expression will be rendered using a LeTex format! See an example notebook.
Total running time of the script: (0 minutes 0.007 seconds)