Skip to content

Commit 68e2969

Browse files
authored
Recover 1.7's behavior (#44736)
Fix #44734.
1 parent b449ea5 commit 68e2969

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

stdlib/LinearAlgebra/src/blas.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ for (fname, elty) in ((:daxpy_,:Float64),
489489
end
490490
end
491491
end
492-
function axpy!(alpha::Number, x::AbstractArray{T}, y::AbstractArray{T}) where T<:BlasFloat
492+
493+
#TODO: replace with `x::AbstractArray{T}` once we separate `BLAS.axpy!` and `LinearAlgebra.axpy!`
494+
function axpy!(alpha::Number, x::Union{DenseArray{T},StridedVector{T}}, y::Union{DenseArray{T},StridedVector{T}}) where T<:BlasFloat
493495
if length(x) != length(y)
494496
throw(DimensionMismatch(lazy"x has length $(length(x)), but y has length $(length(y))"))
495497
end
@@ -561,7 +563,8 @@ for (fname, elty) in ((:daxpby_,:Float64), (:saxpby_,:Float32),
561563
end
562564
end
563565

564-
function axpby!(alpha::Number, x::AbstractArray{T}, beta::Number, y::AbstractArray{T}) where T<:BlasFloat
566+
#TODO: replace with `x::AbstractArray{T}` once we separate `BLAS.axpby!` and `LinearAlgebra.axpby!`
567+
function axpby!(alpha::Number, x::Union{DenseArray{T},AbstractVector{T}}, beta::Number, y::Union{DenseArray{T},AbstractVector{T}},) where T<:BlasFloat
565568
require_one_based_indexing(x, y)
566569
if length(x) != length(y)
567570
throw(DimensionMismatch(lazy"x has length $(length(x)), but y has length $(length(y))"))

stdlib/LinearAlgebra/test/generic.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ end
295295
@test LinearAlgebra.axpy!(α, x, rx, y, ry) == [1 1 1 1; 11 1 1 26]
296296
end
297297

298+
@testset "LinearAlgebra.axp(b)y! for non strides input" begin
299+
a = rand(5, 5)
300+
@test LinearAlgebra.axpby!(1, Hermitian(a), 1, zeros(size(a))) == Hermitian(a)
301+
@test_broken LinearAlgebra.axpby!(1, 1.:5, 1, zeros(5)) == 1.:5
302+
@test LinearAlgebra.axpy!(1, Hermitian(a), zeros(size(a))) == Hermitian(a)
303+
@test LinearAlgebra.axpy!(1, 1.:5, zeros(5)) == 1.:5
304+
end
305+
298306
@testset "norm and normalize!" begin
299307
vr = [3.0, 4.0]
300308
for Tr in (Float32, Float64)

0 commit comments

Comments
 (0)