Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/factorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,33 @@ macro makefrommatrix(fact)
end
end



include("jacobi.jl")
include("ilu0.jl")
include("parallel_jacobi.jl")
include("parallel_ilu0.jl")
include("umfpack_lu.jl")
include("cholmod_cholesky.jl")

@eval begin

@makefrommatrix LUFactorization
@makefrommatrix CholeskyFactorization

@makefrommatrix ILU0Preconditioner
@makefrommatrix JacobiPreconditioner
@makefrommatrix ParallelJacobiPreconditioner
@makefrommatrix ParallelILU0Preconditioner

end

if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available in non-GPL builds
include("umfpack_lu.jl")
include("cholmod_cholesky.jl")

@eval begin

@makefrommatrix LUFactorization
@makefrommatrix CholeskyFactorization

end
end




45 changes: 37 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,20 @@ function test_addition(;m=10,n=10,d=0.1) where {Tv,Ti}
csc2==2*csc
end


function test_operations(n)
A=ExtendableSparseMatrix(n,n)
sprand_sdd!(A)
b=rand(n)
if Base.USE_GPL_LIBS begin
#requires SuiteSparse which is not available on non-GPL builds
x=A\b
Ax=A*x
b≈ Ax
end

else
true
end
end

@testset "Operations" begin
for irun=1:10
Expand All @@ -175,7 +179,7 @@ end
d=0.3*rand()
@test test_addition(m=m,n=n,d=d)
end

@test test_operations(10)
@test test_operations(100)
@test test_operations(1000)
Expand Down Expand Up @@ -261,6 +265,8 @@ function test_precon2(precon,k,l,m;maxiter=10000)
end


if Base.USE_GPL_LIBS begin
#requires SuiteSparse which is not available on non-GPL builds
@testset "preconditioners" begin
@test all(isapprox.(test_precon(ILU0Preconditioner,20,20,20), (true, 1.3535160424212675e-5), rtol=1.0e-5))
@test all(isapprox.(test_precon(JacobiPreconditioner,20,20,20), (true, 2.0406032775945658e-5), rtol=1.0e-5))
Expand All @@ -269,15 +275,15 @@ end
@test all(isapprox.(test_precon(AMGPreconditioner,20,20,20), (true, 6.863753664354144e-7), rtol=1.0e-2))
end


@testset "preconditioners 2" begin
@test all(isapprox.(test_precon2(ILU0Preconditioner(),20,20,20), (true, 1.3535160424212675e-5), rtol=1.0e-5))
@test all(isapprox.(test_precon2(JacobiPreconditioner(),20,20,20), (true, 2.0406032775945658e-5), rtol=1.0e-5))
@test all(isapprox.(test_precon2(ParallelJacobiPreconditioner(),20,20,20), (true, 2.0406032775945658e-5), rtol=1.0e-5))
@test all(isapprox.(test_precon2(ILUTPreconditioner(),20,20,20), (true, 1.2719511868322086e-5), rtol=1.0e-5))
@test all(isapprox.(test_precon2(AMGPreconditioner(),20,20,20), (true, 6.863753664354144e-7), rtol=1.0e-2))
end

end
end


##############################################
Expand All @@ -288,7 +294,12 @@ function test_symmetric(n,uplo)
flush!(A)
SA=Symmetric(A,uplo)
Scsc=Symmetric(A.cscmatrix,uplo)
if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available on non-GPL builds
SA\b≈ Scsc\b
else
true
end
end


Expand All @@ -313,7 +324,12 @@ function test_hermitian(n,uplo)
b=rand(n)
HA=Hermitian(A,uplo)
Hcsc=Hermitian(A.cscmatrix,uplo)
if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available on non-GPL builds
HA\b≈ Hcsc\b
else
true
end
end

@testset "hermitian" begin
Expand Down Expand Up @@ -361,7 +377,8 @@ function test_lu2(k,l,m;lufac=ExtendableSparse.LUFactorization())
all(x1ext.< x2ext)
end


if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available on non-GPL builds
@testset "ExtendableSparse.LUFactorization" begin
@test test_lu1(10,10,10)
@test test_lu1(25,40,1)
Expand All @@ -371,7 +388,10 @@ end
@test test_lu2(25,40,1)
@test test_lu2(1000,1,1)
end
end

if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available on non-GPL builds
@testset "Cholesky" begin
@test test_lu1(10,10,10,lufac=CholeskyFactorization())
@test test_lu1(25,40,1,lufac=CholeskyFactorization())
Expand All @@ -381,7 +401,11 @@ end
@test test_lu2(25,40,1,lufac=CholeskyFactorization())
@test test_lu2(1000,1,1,lufac=CholeskyFactorization())
end
end


if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available on non-GPL builds
@testset "mkl-pardiso" begin
if !Sys.isapple()
@test test_lu1(10,10,10,lufac=MKLPardisoLU())
Expand All @@ -396,8 +420,10 @@ end
# @test test_lu2(25,40,1,lufac=MKLPardisoLU(mtype=2))
# @test test_lu2(1000,1,1,lufac=MKLPardisoLU(mtype=2))
end
end


if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available on non-GPL builds
if Pardiso.PARDISO_LOADED[]
@testset "pardiso" begin
@test test_lu1(10,10,10,lufac=PardisoLU())
Expand All @@ -414,7 +440,7 @@ if Pardiso.PARDISO_LOADED[]

end
end

end


##############################################
Expand Down Expand Up @@ -462,6 +488,9 @@ function test_linearsolve(n)

end

if Base.USE_GPL_LIBS
#requires SuiteSparse which is not available on non-GPL builds
@testset "LinearSolve" begin
test_linearsolve(20)
end
end