question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

scipy.linalg.qr with pivoting=True should return P as (N,N) permutation array instead of (N,) array

See original GitHub issue

I 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:open
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ilayncommented, Nov 11, 2021

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 of n**2 is efficiency wise should be prefferred. I agree nevertheless we have a historical inconsistency across linalg functions.

0reactions
ilayncommented, Apr 26, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found