Skip to content

Commit 9b5c0ce

Browse files
committed
Bug fixes+ type fixes
* Don't check for symmetry in Pardiso * Set proper transpose flag for Pardisoa * Fix type handling for Factorization()
1 parent 5d7095c commit 9b5c0ce

File tree

10 files changed

+30
-42
lines changed

10 files changed

+30
-42
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExtendableSparse"
22
uuid = "95c220a8-a1cf-11e9-0c77-dbfce5f500b3"
33
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>"]
4-
version = "0.6.1"
4+
version = "0.6.2"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"

src/amg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mutable struct AMGPreconditioner{Tv, Ti} <: AbstractPreconditioner{Tv,Ti}
22
A::ExtendableSparseMatrix{Tv,Ti}
3-
fact
3+
fact::AlgebraicMultigrid.Preconditioner
44
max_levels::Int
55
max_coarse::Int
66
function AMGPreconditioner{Tv,Ti}(;max_levels=10, max_coarse=10) where {Tv,Ti}
@@ -13,13 +13,13 @@ end
1313

1414
"""
1515
```
16-
AMGPreconditioner(;max_levels=10, max_coarse=10)
16+
AMGPreconditioner(;max_levels=10, max_coarse=10, valuetype=Float64,indextype=Int64)
1717
AMGPreconditioner(matrix;max_levels=10, max_coarse=10)
1818
```
1919
2020
Create the [`AMGPreconditioner`](@ref) wrapping the Ruge-Stüben AMG preconditioner from [AlgebraicMultigrid.jl](https://github.com/JuliaLinearAlgebra/AlgebraicMultigrid.jl)
2121
"""
22-
AMGPreconditioner(;kwargs...)=AMGPreconditioner{Float64,Int64}(;kwargs...)
22+
AMGPreconditioner(;valuetype::Type=Float64, indextype::Type=Int64,kwargs...)=AMGPreconditioner{valuetype,indextype}(;kwargs...)
2323

2424
@eval begin
2525
@makefrommatrix AMGPreconditioner

src/cholmod_cholesky.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ mutable struct CholeskyFactorization{Tv, Ti} <: AbstractLUFactorization{Tv,Ti}
66
end
77

88
"""
9-
CholeskyFactorization()
9+
CholeskyFactorization(;valuetype=Float64, indextype=Int64)
1010
CholeskyFactorization(matrix)
1111
1212
Default Cholesky factorization via cholmod.
1313
"""
14-
CholeskyFactorization()=CholeskyFactorization{Float64,Int64}(nothing,nothing,0,nothing)
14+
CholeskyFactorization(;valuetype::Type=Float64, indextype::Type=Int64)=CholeskyFactorization{valuetype,indextype}(nothing,nothing,0,nothing)
1515

1616

1717
function update!(cholfact::CholeskyFactorization)

src/factorizations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ LinearAlgebra.ldiv!(fact::AbstractFactorization, v)=ldiv!(fact.fact,v)
117117

118118
macro makefrommatrix(fact)
119119
return quote
120-
$(esc(fact))(A::ExtendableSparseMatrix{Tv,Ti}; kwargs...) where {Tv,Ti} = factorize!($(esc(fact))(),A; kwargs...)
120+
$(esc(fact))(A::ExtendableSparseMatrix{Tv,Ti}; kwargs...) where {Tv,Ti} = factorize!($(esc(fact))(;valuetype=Tv, indextype=Ti),A; kwargs...)
121121
$(esc(fact))(A::SparseMatrixCSC{Tv,Ti}; kwargs...) where {Tv,Ti} = $(esc(fact))(ExtendableSparseMatrix(A); kwargs...)
122122
end
123123
end

src/ilu0.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ end
1212

1313
"""
1414
```
15-
ILU0Preconditioner()
15+
ILU0Preconditioner(;valuetype=Float64,indextype=Int64)
1616
ILU0Preconditioner(matrix)
1717
```
1818
1919
ILU preconditioner with zero fill-in.
2020
"""
21-
ILU0Preconditioner()=ILU0Preconditioner{Float64,Int64}()
21+
ILU0Preconditioner(;valuetype::Type=Float64, indextype::Type=Int64)=ILU0Preconditioner{valuetype,indextype}()
2222

2323

2424
function update!(precon::ILU0Preconditioner{Tv,Ti}) where {Tv,Ti}

src/ilut.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mutable struct ILUTPreconditioner{Tv, Ti} <: AbstractPreconditioner{Tv,Ti}
2-
A::ExtendableSparseMatrix
2+
A::ExtendableSparseMatrix{Tv,Ti}
33
fact::IncompleteLU.ILUFactorization{Tv,Ti}
44
droptol::Float64
55
function ILUTPreconditioner{Tv,Ti}(;droptol=1.0e-3) where {Tv,Ti}
@@ -11,15 +11,15 @@ end
1111

1212
"""
1313
```
14-
ILUTPreconditioner(;droptol=1.0e-3)
14+
ILUTPreconditioner(;droptol=1.0e-3,valuetype=Float64, indextype=Int64)
1515
ILUTPreconditioner(matrix; droptol=1.0e-3)
1616
```
1717
1818
Create the [`ILUTPreconditioner`](@ref) wrapping the one
1919
from [IncompleteLU.jl](https://github.com/haampie/IncompleteLU.jl)
2020
For using this, you need to issue `using IncompleteLU`.
2121
"""
22-
ILUTPreconditioner(;kwargs...)=ILUTPreconditioner{Float64,Int64}(;kwargs...)
22+
ILUTPreconditioner(;valuetype::Type=Float64, indextype::Type=Int64, kwargs...)=ILUTPreconditioner{valuetype,indextype}(;kwargs...)
2323

2424
@eval begin
2525
@makefrommatrix ILUTPreconditioner

src/jacobi.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ end
1111

1212
"""
1313
```
14-
JacobiPreconditioner()
14+
JacobiPreconditioner(;valuetype=Float64, indextype=Int64)
1515
JacobiPreconditioner(matrix)
1616
```
1717
1818
Jacobi preconditioner
1919
"""
20-
JacobiPreconditioner()=JacobiPreconditioner{Float64,Int64}()
20+
JacobiPreconditioner(;valuetype::Type=Float64, indextype::Type=Int64)=JacobiPreconditioner{valuetype,indextype}()
2121

2222
function update!(precon::JacobiPreconditioner{Tv,Ti}) where {Tv,Ti}
2323
flush!(precon.A)

src/parallel_jacobi.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ end
2424

2525
"""
2626
```
27-
ParallelJacobiPreconditioner()
27+
ParallelJacobiPreconditioner(;valuetype=Float64, indextype=Int64)
2828
ParallelJacobiPreconditioner(matrix)
2929
```
3030
3131
Parallel Jacobi preconditioner
3232
"""
33-
ParallelJacobiPreconditioner()=ParallelJacobiPreconditioner{Float64,Int64}()
33+
ParallelJacobiPreconditioner(;valuetype::Type=Float64, indextype::Type=Int64)=ParallelJacobiPreconditioner{valuetype,indextype}()
3434

3535
function LinearAlgebra.ldiv!(u::AbstractArray{T,1} where T, precon::ParallelJacobiPreconditioner, v::AbstractArray{T,1} where T)
3636
invdiag=precon.invdiag

src/pardiso_lu.jl

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PardisoLU{Tv,Ti}() where {Tv,Ti} =PardisoLU{Tv,Ti}(nothing,Pardiso.PardisoSolver
1111

1212
"""
1313
```
14-
PardisoLU()
14+
PardisoLU(;valuetype=Float64, indextype=Int64)
1515
PardisoLU(matrix)
1616
```
1717
@@ -27,20 +27,19 @@ plu=PardisoLU()
2727
Pardiso.set_iparm!(plu.ps,5,13.0)
2828
```
2929
"""
30-
PardisoLU()=PardisoLU{Float64,Int64}(nothing,Pardiso.PardisoSolver(),0)
30+
PardisoLU(;valuetype::Type=Float64, indextype::Type=Int64)=PardisoLU{valuetype,indextype}(nothing,Pardiso.PardisoSolver(),0)
3131

3232

3333
mutable struct MKLPardisoLU{Tv, Ti} <: AbstractPardisoLU{Tv,Ti}
3434
A::Union{ExtendableSparseMatrix{Tv,Ti},Nothing}
3535
ps::Pardiso.MKLPardisoSolver
3636
phash::UInt64
3737
end
38-
MKLPardisoLU{Tv,Ti}() where {Tv,Ti} = MKLPardisoLU{Tv,Ti}(nothing,Pardiso.MKLPardisoSolver(),0)
3938

4039

4140
"""
4241
```
43-
MKLPardisoLU()
42+
MKLPardisoLU(;valuetype=Float64, indextype=Int64)
4443
MKLPardisoLU(matrix)
4544
```
4645
@@ -56,40 +55,29 @@ plu=MKLPardisoLU()
5655
Pardiso.set_iparm!(plu.ps,5,13.0)
5756
```
5857
"""
59-
MKLPardisoLU()=MKLPardisoLU{Float64,Int64}(nothing,Pardiso.MKLPardisoSolver(),0)
60-
61-
62-
function Pardiso.set_matrixtype!(ps, A::ExtendableSparseMatrix)
63-
Acsc=A.cscmatrix
64-
65-
if eltype(Acsc)==Float64 && issymmetric(Acsc)
66-
Pardiso.set_matrixtype!(ps, Pardiso.REAL_SYM)
67-
elseif eltype(Acsc)==Float64
68-
Pardiso.set_matrixtype!(ps, Pardiso.REAL_NONSYM)
69-
elseif eltype(Acsc)==Complex64 && ishermitian(Acsc)
70-
Pardiso.set_matrixtype!(ps, Pardiso.COMPLEX_HERM_INDEF)
71-
elseif eltype(Acsc)==Complex64
72-
Pardiso.set_matrixtype!(ps, Pardiso.COMPLEX_NONYSYM)
73-
else
74-
error("unable to detect matrix type")
75-
end
76-
end
58+
MKLPardisoLU(;valuetype::Type=Float64, indextype::Type=Int64)=MKLPardisoLU{valuetype,indextype}(nothing,Pardiso.MKLPardisoSolver(),0)
7759

7860

7961
function update!(lufact::AbstractPardisoLU{Tv,Ti}) where {Tv, Ti}
8062
ps=lufact.ps
8163
flush!(lufact.A)
8264
Acsc=lufact.A.cscmatrix
83-
if lufact.phash!=lufact.A.phash
65+
if lufact.phash!=lufact.A.phash
8466
Pardiso.pardisoinit(ps)
8567
Pardiso.set_phase!(ps, Pardiso.RELEASE_ALL)
8668
Pardiso.pardiso(ps, Tv[], Acsc, Tv[])
87-
Pardiso.set_matrixtype!(ps,lufact.A)
69+
70+
if Tv<:Complex
71+
Pardiso.set_matrixtype!(ps,Pardiso.COMPLEX_NONSYM)
72+
else
73+
Pardiso.set_matrixtype!(ps,Pardiso.REAL_NONSYM)
74+
end
8875
Pardiso.set_phase!(ps, Pardiso.ANALYSIS_NUM_FACT)
8976
lufact.phash=lufact.A.phash
9077
else
9178
Pardiso.set_phase!(ps, Pardiso.NUM_FACT)
9279
end
80+
Pardiso.fix_iparm!(ps, :N)
9381
Pardiso.pardiso(ps, Tv[], Acsc, Tv[])
9482
lufact
9583
end

src/umfpack_lu.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ end
77

88
"""
99
```
10-
LUFactorization()
10+
LUFactorization(;valuetype=Float64, indextype=Int64)
1111
LUFactorization(matrix)
1212
```
1313
1414
Default Julia LU Factorization based on umfpack.
1515
"""
16-
LUFactorization()=LUFactorization{Float64,Int64}(nothing,nothing,0)
16+
LUFactorization(;valuetype::Type=Float64,indextype::Type=Int64)=LUFactorization{valuetype,indextype}(nothing,nothing,0)
1717

1818

1919
function update!(lufact::LUFactorization)

0 commit comments

Comments
 (0)