scipy.linalg.qr with pivoting=True should return P as (N,N) permutation array instead of (N,) array
See original GitHub issueI am a bit surprised why scipy.linalg.qr
with pivoting=True
returns P
as an array of shape (N,) instead of a proper two dimensional array of shape (N,N) just like scipy.linalg.lu
does. This way I could quickly test if A = P.T@Q@R
just like I can test A=P@L@U
. Is there any reason for this inconsistency?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
scipy.linalg.qr — SciPy v1.9.3 Manual
Compute QR decomposition of a matrix. Calculate the decomposition A = Q R where Q is unitary/orthogonal and R upper triangular.
Read more >Scipy pivoted QR permutation - python - Stack Overflow
During solving the system I reorder the solution using a permutation matrix using the function below. def pvec2pmat(vec): n = len(vec) P =...
Read more >Autodiff with `numpy.linalg.qr` differs from autodiff with `scipy ...
scipy.linalg.qr just returns the array result itself. We should address this.
Read more >jax._src.scipy.linalg - JAX documentation
_src.typing import Array, ArrayLike _T = lambda x: jnp.swapaxes(x, -1, ... _, permutation = lax_linalg.lu(a) dtype = lax.dtype(a) m, n = jnp.shape(a) p...
Read more >The QR Decomposition | ACME
Every m ⇥ n matrix A of rank n m has a QR decomposition, with two main forms. ... results to SciPy's QR...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d argue in this case that LU is the odd one since it is a waste of
n**2
array just to provide sorting keys. I see how this can be unintuitive when you have plenty of memory but nevertheless having an array of n instead ofn**2
is efficiency wise should be prefferred. I agree nevertheless we have a historical inconsistency across linalg functions.I am still considering this since most software has the option
Outputform
as a switch between 1d perm vs 2d full permutation array. It is not a very difficult thing to implement but what we will definitely not do is to choose one that would break code.