Skip to content

Commit dcf579c

Browse files
authored
Multiplication instead of division in triangular eigen test (#1295)
This makes the operation simpler to compile, and reduces TTFX. ```julia julia> using LinearAlgebra julia> A1 = UpperTriangular([1 2; 3 4]) 2×2 UpperTriangular{Int64, Matrix{Int64}}: 1 2 ⋅ 4 julia> vals, vecs = eigen(A1); julia> @time vecs * diagm(0 => vals) / vecs ≈ A1; 1.858678 seconds (4.22 M allocations: 214.301 MiB, 8.50% gc time, 99.97% compilation time) julia> @time vecs * Diagonal(vals) ≈ A1 * vecs; 0.645123 seconds (1.25 M allocations: 62.933 MiB, 17.30% gc time, 99.97% compilation time) ```
1 parent 07725da commit dcf579c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/testtriag.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function test_triangular(elty1_types)
291291
if !(elty1 in (BigFloat, Complex{BigFloat})) # Not handled yet
292292
vals, vecs = eigen(A1)
293293
if (t1 == UpperTriangular || t1 == LowerTriangular) && elty1 != Int # Cannot really handle degenerate eigen space and Int matrices will probably have repeated eigenvalues.
294-
@test vecs * diagm(0 => vals) / vecs A1 atol = sqrt(eps(float(real(one(vals[1]))))) * (opnorm(A1, Inf) * n)^2
294+
@test vecs * Diagonal(vals) A1 * vecs atol = sqrt(eps(float(real(one(vals[1]))))) * (opnorm(A1, Inf) * n)^2
295295
end
296296
end
297297

@@ -409,7 +409,7 @@ function test_triangular(elty1_types)
409409
end
410410
end
411411

412-
for eltyB in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat})
412+
@testset for eltyB in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat})
413413
# Only test methods for the same element type and a single combination of mixed element types
414414
# to avoid too much compilation
415415
if !(elty1 == eltyB || elty1 (ComplexF32, Int) || eltyB (ComplexF32, Int))

0 commit comments

Comments
 (0)