Skip to content

Conversation

@perazz
Copy link
Member

@perazz perazz commented Nov 27, 2024

Compute pseudo-inverse of a square or rectangular matrix using singular value decomposition (SVD).
Array $A$, real or complex, has rank n==2.

The pseudo-inverse $A^{+}$ is a generalization of the matrix inverse and satisfies the following properties:

  • $A \cdot A^{+} \cdot A = A$
  • $A^{+} \cdot A \cdot A^{+} = A^{+}$
  • $(A \cdot A^{+})^H = A \cdot A^{+}$
  • $(A^{+} \cdot A)^H = A^{+} \cdot A$

The user may specify an eigenvalue cutoff relative tolerance, rtol.

Proposed interface

  • ap = pinv(a [, rtol] [, err]): function interface
  • call pseudoinvert(a, ap [, rtol] [, err]): subroutine interface (preallocated ap)
  • .pinv.a: operator interface

Key facts

Progress

  • base implementation
  • tests
  • documentation
  • submodule
  • examples

Prior art

  • Numpy: linalg.pinv(a, rcond=None, hermitian=False, *, rtol=<no value>)
  • Scipy: pinv(a, *, atol=None, rtol=None, return_rank=False, check_finite=True)
  • Matlab: B = pinv(a [,tol])

cc: @jvdp1 @jalvesz @Beliavsky @CRquantum @fortran-lang/stdlib

@perazz perazz marked this pull request as ready for review November 27, 2024 17:18
@perazz perazz changed the title linalg: Moore-Penrose pseudo-inverse linalg: Moore-Penrose pseudo-inverse (pinv) Nov 28, 2024
Copy link
Member

@jvdp1 jvdp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @perazz . It looks really good to me!

perazz and others added 3 commits December 21, 2024 12:37
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
@perazz
Copy link
Member Author

perazz commented Dec 26, 2024

Thank you for the reviews and the approvals @jalvesz @jvdp1, I believe all fixes are addressed and no comments for a while, so I will merge this.

@perazz perazz merged commit 195d4a5 into fortran-lang:master Dec 26, 2024
15 checks passed
@perazz perazz deleted the pseudo_inverse branch December 26, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants