Skip to content

Commit

Permalink
Aggressive constprop in LinearAlgebra.wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Oct 4, 2023
1 parent b790cf8 commit 811512c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ wrapper_char(A::Hermitian) = A.uplo == 'U' ? 'H' : 'h'
wrapper_char(A::Hermitian{<:Real}) = A.uplo == 'U' ? 'S' : 's'
wrapper_char(A::Symmetric) = A.uplo == 'U' ? 'S' : 's'

function wrap(A::AbstractVecOrMat, tA::AbstractChar)
Base.@constprop :aggressive function wrap(A::AbstractVecOrMat, tA::AbstractChar)
if tA == 'N'
return A
elseif tA == 'T'
Expand Down
8 changes: 8 additions & 0 deletions stdlib/LinearAlgebra/test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ mul_wrappers = [
m -> adjoint(m),
m -> transpose(m)]

@testset "wrap" begin
f(A) = LinearAlgebra.wrap(A, 'N')
A = ones(1,1)
@test @inferred(f(A)) === A
g(A) = LinearAlgebra.wrap(A, 'T')
@test @inferred(g(A)) === transpose(A)
end

@testset "matrices with zero dimensions" begin
for (dimsA, dimsB, dimsC) in (
((0, 5), (5, 3), (0, 3)),
Expand Down

0 comments on commit 811512c

Please sign in to comment.