.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/01_solve.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_01_solve.py: 1. Example: Solving ------------------- Here we create a random row wise flattened matrix M_flat and a random right hand side for the pentadiagonal equation system. After solving we calculate the absolute difference between the right hand side and the product of the matrix (which is transformed to a full quadratic one) and the solution of the system. .. GENERATED FROM PYTHON SOURCE LINES 12-28 .. rst-class:: sphx-glr-script-out .. code-block:: none 1.7475031199865043e-06 | .. code-block:: Python import numpy as np import pentapy as pp size = 1000 # create a flattened pentadiagonal matrix M_flat = (np.random.random((5, size)) - 0.5) * 1e-5 V = np.random.random(size) * 1e5 # solve the LES with M_flat as row-wise flattened matrix X = pp.solve(M_flat, V, is_flat=True) # create the corresponding matrix for checking M = pp.create_full(M_flat, col_wise=False) # calculate the error print(np.max(np.abs(np.dot(M, X) - V))) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.007 seconds) .. _sphx_glr_download_examples_01_solve.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01_solve.ipynb <01_solve.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01_solve.py <01_solve.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01_solve.zip <01_solve.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_