Skip to content

Commit af70c13

Browse files
authoredFeb 21, 2022
Merge pull request #35 from gridap/complex_tests
Test complex-valued systems
2 parents 4d8166b + a81f165 commit af70c13

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
 

‎test/LinearSolver.jl

+46
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ if Int == Int64
6969
test_linear_solver(ps, A, b, x)
7070
end
7171

72+
I = Vector{Int32}(); J = Vector{Int32}(); V = Vector{Complex{Float64}}()
73+
for (ik, jk, vk) in zip(I_,J_,V_)
74+
push_coo!(SparseMatrixCSC,I,J,V,ik,jk,vk)
75+
end
76+
finalize_coo!(SparseMatrixCSC,I,J,V,rows, cols)
77+
A = sparse(I,J,V,rows,cols)
78+
b = ones(Complex{Float64},size(A)[2])
79+
x = similar(b)
80+
ps = PardisoSolver(msglvl=GridapPardiso.MSGLVL_VERBOSE)
81+
ss = symbolic_setup(ps, A)
82+
ns = numerical_setup(ss, A)
83+
solve!(x, ns, b)
84+
@test maximum(abs.(A*x-b)) < tol
85+
test_linear_solver(ps, A, b, x)
86+
7287
#####################################################
7388
# SparseMatrixCSR
7489
#####################################################
@@ -130,6 +145,21 @@ for Bi in (0,1)
130145
@test maximum(abs.(A*x-b)) < tol
131146
test_linear_solver(ps, A, b, x)
132147
end
148+
149+
I = Vector{Int32}(); J = Vector{Int32}(); V = Vector{Complex{Float64}}()
150+
for (ik, jk, vk) in zip(I_,J_,V_)
151+
push_coo!(SparseMatrixCSR,I,J,V,ik,jk,vk)
152+
end
153+
finalize_coo!(SparseMatrixCSR,I,J,V,rows,cols)
154+
A = sparsecsr(Val{Bi}(),I,J,V,rows,cols)
155+
b = ones(Complex{Float64},size(A)[2])
156+
x = similar(b)
157+
ps = PardisoSolver(msglvl=GridapPardiso.MSGLVL_VERBOSE)
158+
ss = symbolic_setup(ps, A)
159+
ns = numerical_setup(ss, A)
160+
solve!(x, ns, b)
161+
@test maximum(abs.(A*x-b)) < tol
162+
test_linear_solver(ps, A, b, x)
133163
end
134164

135165
#####################################################
@@ -197,6 +227,22 @@ for Bi in (0,1)
197227
@test maximum(abs.(A*x-b)) < tol
198228
test_linear_solver(ps, A, b, x)
199229
end
230+
231+
I = Vector{Int32}(); J = Vector{Int32}(); V = Vector{Complex{Float64}}()
232+
for (ik, jk, vk) in zip(I_,J_,V_)
233+
push_coo!(SymSparseMatrixCSR,I,J,V,ik,jk,vk)
234+
end
235+
finalize_coo!(SymSparseMatrixCSR,I,J,V,rows,cols)
236+
A = symsparsecsr(Val{Bi}(),I,J,V,rows,cols)
237+
b = ones(Complex{Float64},size(A)[2])
238+
x = similar(b)
239+
ps = PardisoSolver(msglvl=GridapPardiso.MSGLVL_VERBOSE)
240+
ss = symbolic_setup(ps, A)
241+
ns = numerical_setup(ss, A)
242+
solve!(x, ns, b)
243+
@test maximum(abs.(A*x-b)) < tol
244+
test_linear_solver(ps, A, b, x)
245+
200246
end
201247

202248
end

0 commit comments

Comments
 (0)