Skip to content

Commit

Permalink
Tests for in-place kron (#36488)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Karrasch <Daniel.Karrasch@gmx.de>
  • Loading branch information
kshyatt and dkarrasch authored Jul 3, 2020
1 parent b79a6d1 commit 66f41c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ function kron(a::AbstractMatrix{T}, b::AbstractMatrix{S}) where {T,S}
end

kron!(c::AbstractVecOrMat, a::AbstractVecOrMat, b::Number) = mul!(c, a, b)
kron!(c::AbstractVecOrMat, a::Number, b::AbstractVecOrMat) = mul!(c, a, b)

Base.@propagate_inbounds function kron!(c::AbstractVector, a::AbstractVector, b::AbstractVector)
C = reshape(c, length(a)*length(b), 1)
Expand Down
13 changes: 13 additions & 0 deletions stdlib/LinearAlgebra/test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,19 @@ end
@test kron(b',2) == [8 10 12]
end

@testset "kron!" begin
a = [1.0, 0.0]
b = [0.0, 1.0]
@test kron!([1.0, 0.0], b, 0.5) == [0.0; 0.5]
@test kron!([1.0, 0.0], 0.5, b) == [0.0; 0.5]
c = Vector{Float64}(undef, 4)
kron!(c, a, b)
@test c == [0.0; 1.0; 0.0; 0.0]
c = Matrix{Float64}(undef, 2, 2)
kron!(c, a, b')
@test c == [0.0 1.0; 0.0 0.0]
end

@testset "kron adjoint" begin
a = [1+im, 2, 3]
b = [4, 5, 6+7im]
Expand Down

6 comments on commit 66f41c5

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible issues were detected. A full report can be found here. cc @maleadt

Please sign in to comment.