.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/04_perform_full_mat.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_04_perform_full_mat.py: 4. Example: Performance for full matrices ----------------------------------------- Here we compare all algorithms for solving pentadiagonal systems provided by pentapy (except umf) using a full quadratic matrix as input. To use this script you need to have the following packages installed: * scipy * perfplot * matplotlib .. GENERATED FROM PYTHON SOURCE LINES 14-69 .. image-sg:: /examples/images/sphx_glr_04_perform_full_mat_001.png :alt: 04 perform full mat :srcset: /examples/images/sphx_glr_04_perform_full_mat_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Overall ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 Kernels ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 | .. code-block:: Python import numpy as np import perfplot from pentapy import solve, tools def get_les(size): mat = (np.random.random((5, size)) - 0.5) * 1e-5 V = np.array(np.random.random(size) * 1e5) M = tools.create_full(mat) return M, V def solve_1(in_val): """PTRANS-I""" mat, V = in_val return solve(mat, V, is_flat=False, solver=1) def solve_2(in_val): """PTRANS-II""" mat, V = in_val return solve(mat, V, is_flat=False, solver=2) def solve_3(in_val): mat, V = in_val return solve(mat, V, is_flat=False, solver=3) def solve_4(in_val): mat, V = in_val return solve(mat, V, is_flat=False, solver=4) def solve_5(in_val): mat, V = in_val return np.linalg.solve(mat, V) perfplot.show( setup=get_les, kernels=[solve_1, solve_2, solve_3, solve_4, solve_5], labels=[ "PTRANS-I", "PTRANS-II", "scipy.linalg.solve_banded", "scipy.sparse.linalg.spsolve", "numpy.linalg.solve", ], n_range=[2**k for k in range(2, 13)], xlabel="Size [n]", logy=True, ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 36.172 seconds) .. _sphx_glr_download_examples_04_perform_full_mat.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 04_perform_full_mat.ipynb <04_perform_full_mat.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 04_perform_full_mat.py <04_perform_full_mat.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 04_perform_full_mat.zip <04_perform_full_mat.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_