Skip to content

Commit caeb995

Browse files
committed
Avoid Int32 overflow to work around an issue in Julia base
1 parent 3fc63f0 commit caeb995

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/testsuite/linalg.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,25 @@ function test_linalg(AT)
6262
end
6363

6464
@testset "$T gemv y := $f(A) * x * a + y * b" for f in (identity, transpose, adjoint), T in supported_eltypes()
65-
@test compare(*, AT, f(rand(T, 4, 4)), rand(T, 4))
66-
@test compare(mul!, AT, rand(T, 4), f(rand(T, 4, 4)), rand(T, 4))
67-
@test compare(mul!, AT, rand(T, 4), f(rand(T, 4, 4)), rand(T, 4), Ref(T(4)), Ref(T(5)))
65+
y, A, x = rand(T, 4), rand(T, 4, 4), rand(T, 4)
66+
67+
# workaround for https://github.com/JuliaLang/julia/issues/35163#issue-584248084
68+
T <: Integer && (y .%= T(10); A .%= T(10); x .%= T(10))
69+
70+
@test compare(*, AT, f(A), x)
71+
@test compare(mul!, AT, y, f(A), x)
72+
@test compare(mul!, AT, y, f(A), x, Ref(T(4)), Ref(T(5)))
6873
end
6974

7075
@testset "$T gemm C := $f(A) * $g(B) * a + C * b" for f in (identity, transpose, adjoint), g in (identity, transpose, adjoint), T in supported_eltypes()
71-
@test compare(*, AT, f(rand(T, 4, 4)), g(rand(T, 4, 4)))
72-
@test compare(mul!, AT, rand(T, 4, 4), f(rand(T, 4, 4)), g(rand(T, 4, 4)))
73-
@test compare(mul!, AT, rand(T, 4, 4), f(rand(T, 4, 4)), g(rand(T, 4, 4)), Ref(T(4)), Ref(T(5)))
76+
A, B, C = rand(T, 4, 4), rand(T, 4, 4), rand(T, 4, 4)
77+
78+
# workaround for https://github.com/JuliaLang/julia/issues/35163#issue-584248084
79+
T <: Integer && (A .%= T(10); B .%= T(10); C .%= T(10))
80+
81+
@test compare(*, AT, f(A), g(B))
82+
@test compare(mul!, AT, C, f(A), g(B))
83+
@test compare(mul!, AT, C, f(A), g(B), Ref(T(4)), Ref(T(5)))
7484
end
7585

7686
@testset "lmul! and rmul!" for (a,b) in [((3,4),(4,3)), ((3,), (1,3)), ((1,3), (3))], T in supported_eltypes()

0 commit comments

Comments
 (0)