Note
Click here to download the full example code
Matrix Multiplication¶
This example shows how to use the pylops_gpu.MatrixMult
operator
to perform Matrix inversion of the following linear system.
\[\mathbf{y}= \mathbf{A} \mathbf{x}\]
For square \(\mathbf{A}\), we will use the
pylops_gpu.optimization.leastsquares.cg
solver.
Out:
PyLops-gpu working on cpu...
Let’s define the size N
of thesquare matrix \(\mathbf{A}\) and
fill the matrix with random numbers
We can now apply the forward operator to create the data vector \(\mathbf{y}\)
and use /
to solve the system by means of an explicit solver.
If you prefer to customize the solver (e.g., choosing the number of
iterations) use the method div
instead.
Out:
x tensor([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1.])
xest tensor([1.0778, 0.5838, 0.4961, 0.9645, 0.4359, 0.7856, 0.8009, 1.0520, 0.8892,
1.0553, 0.7420, 1.1305, 1.0049, 0.9770, 1.4189, 0.7818, 1.0504, 1.1458,
1.0992, 1.0956])
Total running time of the script: ( 0 minutes 0.006 seconds)