qr_decomposition

qr_decomposition(a)

QR decomposition.

Mirrors the C# QRDecomposition class (Householder reflections): decomposes the M x N array a into an M x M orthogonal array q and an M x N upper triangular array r such that q @ r reproduces a. The C# RMatrix property is named r here (R has no naming collision in this package, unlike in the C# codebase).

Parameters

Name Type Description Default
a array_like A 2D array, M x N. required

Returns

Name Type Description
dict {"q": ndarray (M, M), "r": ndarray (M, N)}.

Examples

>>> from corehydropy import qr_decomposition
>>> a = [[1, 1, 1], [0, 2, 5], [2, 5, -1]]
>>> qr = qr_decomposition(a)
>>> import numpy as np
>>> np.allclose(qr["q"] @ qr["r"], a)
True