Skip to content

Commit 8e4202a

Browse files
authored
Merge pull request #22191 from fredrikekre/fe/lu-testfix
Actually test solving ModInt example with lufact
2 parents aab564a + 7ee1038 commit 8e4202a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/linalg/generic.jl

+8-6
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ end
316316
struct ModInt{n}
317317
k
318318
ModInt{n}(k) where {n} = new(mod(k,n))
319+
ModInt{n}(k::ModInt{n}) where {n} = k
319320
end
320321

321322
Base.:+(a::ModInt{n}, b::ModInt{n}) where {n} = ModInt{n}(a.k + b.k)
@@ -329,14 +330,15 @@ Base.zero(::Type{ModInt{n}}) where {n} = ModInt{n}(0)
329330
Base.zero(::ModInt{n}) where {n} = ModInt{n}(0)
330331
Base.one(::Type{ModInt{n}}) where {n} = ModInt{n}(1)
331332
Base.one(::ModInt{n}) where {n} = ModInt{n}(1)
333+
Base.transpose(a::ModInt{n}) where {n} = a # see Issue 20978
334+
335+
A = [ModInt{2}(1) ModInt{2}(0); ModInt{2}(1) ModInt{2}(1)]
336+
b = [ModInt{2}(1), ModInt{2}(0)]
337+
338+
@test A*(lufact(A, Val{false})\b) == b
332339

333340
# Needed for pivoting:
334341
Base.abs(a::ModInt{n}) where {n} = a
335342
Base.:<(a::ModInt{n}, b::ModInt{n}) where {n} = a.k < b.k
336-
Base.transpose(a::ModInt{n}) where {n} = a # see Issue 20978
337-
338-
A = [ ModInt{2}(1) ModInt{2}(0) ; ModInt{2}(1) ModInt{2}(1) ]
339-
b = [ ModInt{2}(1), ModInt{2}(0) ]
340343

341-
@test A*(A\b) == b
342-
@test_nowarn lufact( A, Val{true} )
344+
@test A*(lufact(A, Val{true})\b) == b

0 commit comments

Comments
 (0)