-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[LAPACK] Interface lacpy! and add a Julia version copytrito! #51909
Conversation
It'll probably be better to specialise |
Triangular wrappers only work with square matrices. It's a major issue when we want to copy the L / R factor of an LQ / QR decomposition. For the performance of the LAPACK version, I don't think that we have a difference for the backend OpenBLAS. |
Slightly Off-topic here, but we need to have some sort of a global preference for picking a non-default BLAS. |
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.
I agree with @jishnub on both points: (a) do we need the LAPACK version at all, or would it suffice to have the generic one, and (b) can't we have a more Julian name for the generic function (that may or may not call LAPACK for strided matrices of BlasFloats elements? Perhaps we could target at something closer to LinearAlgebra.copytri!
(it copies a triangle into the opposite triangle of the same matrix), perhaps copytotri!
?
stdlib/LinearAlgebra/src/generic.jl
Outdated
Copies all or part of a matrix A to another matrix B. | ||
uplo specifies the part of the matrix A to be copied to B. | ||
Set `uplo = 'L'` for the lower triangular part, `uplo = 'U'` | ||
for the upper triangular part, any other character for all | ||
the matrix A. |
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.
I'm not 100% sure, but I think the arguments/variables should be wrapped in ``
, like A
and uplo
.
stdlib/LinearAlgebra/src/generic.jl
Outdated
3 4 | ||
``` | ||
""" | ||
function lacpy!(uplo::AbstractChar, A::AbstractMatrix, B::AbstractMatrix) |
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.
This cries for require_one_based_indexing
, or checks on axes
. The following code may then be annotated with @inbounds
.
I like the idea |
7c4be2e
to
bd64930
Compare
bd64930
to
99ae394
Compare
stdlib/LinearAlgebra/src/generic.jl
Outdated
function copytotri!(uplo::AbstractChar, A::AbstractMatrix, B::AbstractMatrix) | ||
require_one_based_indexing(A, B) | ||
LinearAlgebra.BLAS.chkuplo(uplo) | ||
m, n = size(A) |
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.
You definitely need to check the size of B
as well, otherwise (if B
is smaller than A
) some indices might be out-of-bounds. Judging by the LAPACK version below, you do want to allow that B
is larger than A
, right?
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.
Yes, we should allow B
to be larger than A
.
1614c4a
to
2db81ef
Compare
574c85d
to
43ba8cb
Compare
e5c00a0
to
58b513d
Compare
@dkarrasch @jishnub The errors on CI are unrelated to this PR. |
I'm rerunning the CI. If no other concerns, we should merge. |
4e1b45f
to
1d0c2fc
Compare
Well, naming is hard. I had no better idea, I just thought that picking the BLAS name for a generic Julia function is not quite right, but other than that I have no strong opinions. Would |
This seems better, as |
I renamed |
1d0c2fc
to
b53e54b
Compare
@ViralBShah @dkarrasch @jishnub |
The PR adds a function
lacpy!
to easily copy a triangular part of a square or rectangular dense matrix.