Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linalg: Moore-Penrose pseudo-inverse (pinv) #899

Merged
merged 19 commits into from
Dec 26, 2024

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
doc/specs/stdlib_linalg.md Outdated Show resolved Hide resolved
src/stdlib_linalg_pinv.fypp Outdated Show resolved Hide resolved
src/stdlib_linalg_pinv.fypp Outdated Show resolved Hide resolved
src/stdlib_linalg_pinv.fypp Outdated Show resolved Hide resolved
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!

doc/specs/stdlib_linalg.md Outdated Show resolved Hide resolved
doc/specs/stdlib_linalg.md Outdated Show resolved Hide resolved
doc/specs/stdlib_linalg.md Outdated Show resolved Hide resolved
perazz and others added 3 commits December 21, 2024 12:37
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants