-
-
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
add spr! to LinearAlgebra.BLAS #42830
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ export | |
sbmv!, | ||
sbmv, | ||
spmv!, | ||
spr!, | ||
symv!, | ||
symv, | ||
trsv!, | ||
|
@@ -1145,6 +1146,71 @@ Return the updated `y`. | |
""" | ||
spmv! | ||
|
||
### spr!, (SP) symmetric packed matrix-vector operation defined as A := alpha*x*x' + A | ||
for (fname, elty) in ((:dspr_, :Float64), | ||
(:sspr_, :Float32)) | ||
@eval begin | ||
function spr!(uplo::AbstractChar, | ||
n::Integer, | ||
α::$elty, | ||
x::Union{Ptr{$elty}, AbstractArray{$elty}}, | ||
incx::Integer, | ||
AP::Union{Ptr{$elty}, AbstractArray{$elty}}) | ||
|
||
ccall((@blasfunc($fname), libblastrampoline), Cvoid, | ||
(Ref{UInt8}, # uplo, | ||
Ref{BlasInt}, # n, | ||
Ref{$elty}, # α, | ||
Ptr{$elty}, # x, | ||
Ref{BlasInt}, # incx, | ||
Ptr{$elty}, # AP, | ||
Clong), # length of uplo | ||
uplo, | ||
n, | ||
α, | ||
x, | ||
incx, | ||
AP, | ||
1) | ||
return AP | ||
end | ||
end | ||
end | ||
|
||
function spr!(uplo::AbstractChar, | ||
α::Real, x::Union{DenseArray{T}, AbstractVector{T}}, | ||
AP::Union{DenseArray{T}, AbstractVector{T}}) where {T <: BlasReal} | ||
require_one_based_indexing(AP, x) | ||
N = length(x) | ||
dkarrasch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if 2*length(AP) < N*(N + 1) | ||
throw(DimensionMismatch("Packed symmetric matrix A has size smaller than length(x) = $(N).")) | ||
end | ||
return spr!(uplo, N, convert(T, α), x, stride(x, 1), AP) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will use the wrong pointer for (Support for negative strides in |
||
end | ||
|
||
""" | ||
spr!(uplo, α, x, AP) | ||
Update matrix `A` as `α*A*x*x'`, where `A` is a symmetric matrix provided | ||
in packed format `AP` and `x` is a vector. | ||
With `uplo = 'U'`, the array AP must contain the upper triangular part of the | ||
symmetric matrix packed sequentially, column by column, so that `AP[1]` | ||
contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[1, 2]` and `A[2, 2]` | ||
respectively, and so on. | ||
With `uplo = 'L'`, the array AP must contain the lower triangular part of the | ||
symmetric matrix packed sequentially, column by column, so that `AP[1]` | ||
contains `A[1, 1]`, `AP[2]` and `AP[3]` contain `A[2, 1]` and `A[3, 1]` | ||
respectively, and so on. | ||
The scalar input `α` must be real. | ||
The array inputs `x` and `AP` must all be of `Float32` or `Float64` type. | ||
Return the updated `A`. | ||
dkarrasch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
spr! | ||
|
||
### hbmv, (HB) Hermitian banded matrix-vector multiplication | ||
for (fname, elty) in ((:zhbmv_,:ComplexF64), | ||
(:chbmv_,:ComplexF32)) | ||
|
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.
Is there a usecase for
x::DenseArray
or would it make more sense to restrict it to justAbstractVector
?For
AP
, on the other hand, I don’t think we should allowAbstractVector
without checking that its stride is compatible, i.e.,chkstride1(AP)
.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 too wondered about
x::DenseArray
. but that is whatspmv!
inputs. is there a use case for it there?smpv!
also does not check the stride of AP. happy to change it here, but would be nice to keep everything in sync.