Skip to content

Commit e622f96

Browse files
committed
Augment tests with complex number systems and those with mixed types
1 parent 736675b commit e622f96

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/basictests.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@ x1 = zero(b);
1515
A2 = A / 2;
1616
b2 = rand(n);
1717
x2 = zero(b);
18+
# Test system with complex numbers
19+
A3 = A .+ rand(n) .* im;
20+
b3 = rand(n);
21+
x3 = zero(b);
22+
# Test system with mixed types
23+
A4 = (A / 4) .|> Float32;
24+
b4 = rand(n) .|> Float32;
25+
x4 = zero(b) .|> Float32;
1826

1927
prob1 = LinearProblem(A1, b1; u0 = x1)
2028
prob2 = LinearProblem(A2, b2; u0 = x2)
29+
prob3 = LinearProblem(A3, b3; u0 = x3)
30+
prob4 = LinearProblem(A4, b4; u0 = x4)
2131

2232
cache_kwargs = (; verbose = true, abstol = 1e-8, reltol = 1e-8, maxiter = 30)
2333

@@ -28,6 +38,10 @@ function test_interface(alg, prob1, prob2)
2838
A2 = prob2.A
2939
b2 = prob2.b
3040
x2 = prob2.u0
41+
A3 = prob3.A
42+
b3 = prob3.b
43+
A4 = prob4.A
44+
b4 = prob4.b
3145

3246
sol = solve(prob1, alg; cache_kwargs...)
3347
@test A1 * sol.u b1
@@ -44,6 +58,22 @@ function test_interface(alg, prob1, prob2)
4458
sol = solve!(cache; cache_kwargs...)
4559
@test A2 * sol.u b2
4660

61+
# Test complex numbers via cache interface
62+
cache.A = A3
63+
cache.b = b3
64+
sol = solve!(cache; cache_kwargs...)
65+
@test A3 * sol.u b3
66+
67+
# Test mixed types via cache interface
68+
cache.A = A4
69+
cache.b = b4
70+
sol = solve!(cache; cache_kwargs...)
71+
@test A4 * sol.u b4
72+
73+
# Test mixed types from scratch
74+
sol = solve(prob4, alg; cache_kwargs...)
75+
@test A4 * sol.u b4
76+
4777
return
4878
end
4979

0 commit comments

Comments
 (0)