-
Notifications
You must be signed in to change notification settings - Fork 178
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
Conversation
From Fortran Monthly call:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a few comments. LGTM. Thank you
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
Co-authored-by: jalvesz <102541118+jalvesz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you @perazz for this addition.
Thank you @jvdp1. I think it makes sense to wait for a bit longer, and then merge if there are no further comments. |
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 writeexclude unsupportedxdp
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