.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/simulation_and_analysis/qr_matrix_inverse_precedence.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_simulation_and_analysis_qr_matrix_inverse_precedence.py: ======================================= Precedence of QR-based matrix inversion ======================================= Compare precedence histograms for the four QR-based inverse modes of a 4-by-4 real symmetric matrix. All graphs use Householder reflections and separate arithmetic operations, so the inverse recovery strategy is the only difference between the subplots. Change ``method`` to ``"givens"`` to compare graphs based on Givens rotations instead. Each bar counts the computational operations in one precedence step. Inputs, outputs, constants, delays, DontCare, and Sink operations are excluded. These steps describe dependencies, without operation latencies or resource limits. .. GENERATED FROM PYTHON SOURCE LINES 19-21 Generate one graph for each inverse recovery strategy. The two implicit-Q variants retain the transformation parameters instead of constructing Q. .. GENERATED FROM PYTHON SOURCE LINES 21-34 .. code-block:: Python import matplotlib.pyplot as plt from b_asic.sfg_generators import qr_matrix_inverse method = "householder" variants = [ ("eqs", "eqs: explicit Q and back substitution"), ("mult", "mult: triangular inverse and matrix product"), ("implicitq", "implicitq: triangular inverse and transformations"), ("implicitq_eqs", "implicitq_eqs: transformed unit vectors and solves"), ] .. GENERATED FROM PYTHON SOURCE LINES 35-39 Use shared axes to compare both the depth of the graphs and the available parallelism. Zero-count steps retain their original positions. The ``eqs`` and ``implicitq_eqs`` histograms can coincide: constructing the latter one column at a time does not itself impose a sequential hardware schedule. .. GENERATED FROM PYTHON SOURCE LINES 39-50 .. code-block:: Python fig, axes = plt.subplots( 2, 2, figsize=(12, 7), sharex=True, sharey=True, layout="constrained" ) for ax, (mode, title) in zip(axes.flat, variants, strict=True): sfg = qr_matrix_inverse(4, mode=mode, method=method, pe=None) sfg.precedence_histogram(ax=ax) ax.set_title(title, fontsize=10) fig.suptitle(f"Precedence of 4 x 4 QR-based matrix inversion ({method.capitalize()})") plt.show() .. image-sg:: /examples/simulation_and_analysis/images/sphx_glr_qr_matrix_inverse_precedence_001.png :alt: Precedence of 4 x 4 QR-based matrix inversion (Householder), eqs: explicit Q and back substitution, mult: triangular inverse and matrix product, implicitq: triangular inverse and transformations, implicitq_eqs: transformed unit vectors and solves :srcset: /examples/simulation_and_analysis/images/sphx_glr_qr_matrix_inverse_precedence_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.339 seconds) .. _sphx_glr_download_examples_simulation_and_analysis_qr_matrix_inverse_precedence.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: qr_matrix_inverse_precedence.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: qr_matrix_inverse_precedence.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: qr_matrix_inverse_precedence.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_