-
Notifications
You must be signed in to change notification settings - Fork 161
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: QR factorization #832
Open
perazz
wants to merge
17
commits into
fortran-lang:master
Choose a base branch
from
perazz:qr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From Fortran Montly call:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Compute the QR factorization of a$A = Q R $ , where q is orthonormal and r is upper-triangular. Matrix $A$ has size $m\ge n$ .$A = ( Q_1 Q_2 ) \cdot ( \frac{R_1}{0})$ . The user may want the full problem or the reduced problem only $A = Q_1 R_1 $ .
real
orcomplex
matrix:[m,n]
, withBased on LAPACK General QR factorization (
*GEQRF
) and ordered matrix output (*ORGQR
,*UNGQR
).Option for
full
orreduced
factorization: givenk = min(m,n)
, one can writexdp
pure subroutine
interfacesPrior art
linalg.qr(a, mode={'reduced', 'complete', 'r', 'raw')
scipy.linalg.qr(a, overwrite_a=False, lwork=None, mode='full', pivoting=False, check_finite=True)
Proposed implementation
call qr(A,Q,R [, overwrite_a] [, storage] [, err])
:pure
subroutine interfacecall qr_space(A, lwork [, err])
query internal storage size for pre-allocation.Special care was devoted to re-using internal storage such that a
pure
and totally allocation-less method is available, if the user provides pre-allocated working arraystorage
. Because LAPACK internals require two steps ("raw" factorization + ordered matrix output), temporary storage is borrowed from eithera
,q
, orr
during the operations.Both NumPy and SciPy have a cryptic UI that requires to provide a "method":
full
,reduced
raw
economic
,r
. I believe this is hard to understand. Instead, the current version proposes to decide it autonomously:shape(Q)==[m,m]
andshape(R)==[m,n]
, perform a full factorization,shape(Q)==[m,k]
andshape(R)==[k,n]
, perform a "reduced" factorization,In other words, the user decides what method is required based on the size of the arrays passed to
qr
.cc: @fortran-lang/stdlib @jvdp1 @jalvesz @everythingfunctional