Skip to content

Commit

Permalink
Recover 1.7's behavior (#44736)
Browse files Browse the repository at this point in the history
Fix #44734.
  • Loading branch information
N5N3 authored Mar 25, 2022
1 parent b449ea5 commit 68e2969
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stdlib/LinearAlgebra/src/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ for (fname, elty) in ((:daxpy_,:Float64),
end
end
end
function axpy!(alpha::Number, x::AbstractArray{T}, y::AbstractArray{T}) where T<:BlasFloat

#TODO: replace with `x::AbstractArray{T}` once we separate `BLAS.axpy!` and `LinearAlgebra.axpy!`
function axpy!(alpha::Number, x::Union{DenseArray{T},StridedVector{T}}, y::Union{DenseArray{T},StridedVector{T}}) where T<:BlasFloat
if length(x) != length(y)
throw(DimensionMismatch(lazy"x has length $(length(x)), but y has length $(length(y))"))
end
Expand Down Expand Up @@ -561,7 +563,8 @@ for (fname, elty) in ((:daxpby_,:Float64), (:saxpby_,:Float32),
end
end

function axpby!(alpha::Number, x::AbstractArray{T}, beta::Number, y::AbstractArray{T}) where T<:BlasFloat
#TODO: replace with `x::AbstractArray{T}` once we separate `BLAS.axpby!` and `LinearAlgebra.axpby!`
function axpby!(alpha::Number, x::Union{DenseArray{T},AbstractVector{T}}, beta::Number, y::Union{DenseArray{T},AbstractVector{T}},) where T<:BlasFloat
require_one_based_indexing(x, y)
if length(x) != length(y)
throw(DimensionMismatch(lazy"x has length $(length(x)), but y has length $(length(y))"))
Expand Down
8 changes: 8 additions & 0 deletions stdlib/LinearAlgebra/test/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ end
@test LinearAlgebra.axpy!(α, x, rx, y, ry) == [1 1 1 1; 11 1 1 26]
end

@testset "LinearAlgebra.axp(b)y! for non strides input" begin
a = rand(5, 5)
@test LinearAlgebra.axpby!(1, Hermitian(a), 1, zeros(size(a))) == Hermitian(a)
@test_broken LinearAlgebra.axpby!(1, 1.:5, 1, zeros(5)) == 1.:5
@test LinearAlgebra.axpy!(1, Hermitian(a), zeros(size(a))) == Hermitian(a)
@test LinearAlgebra.axpy!(1, 1.:5, zeros(5)) == 1.:5
end

@testset "norm and normalize!" begin
vr = [3.0, 4.0]
for Tr in (Float32, Float64)
Expand Down

0 comments on commit 68e2969

Please sign in to comment.