Skip to content

Commit 283cd23

Browse files
Merge pull request #187 from SciML/assumptions
Add an assumptions mechanism for type-stable default help, and nonsquare
2 parents bc272f5 + 52f5da5 commit 283cd23

File tree

7 files changed

+207
-225
lines changed

7 files changed

+207
-225
lines changed

docs/make.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ makedocs(sitename = "LinearSolve.jl",
99
authors = "Chris Rackauckas",
1010
modules = [LinearSolve, LinearSolve.SciMLBase],
1111
clean = true, doctest = false,
12-
strict=[
13-
:doctest,
14-
:linkcheck,
15-
:parse_error,
16-
:example_block,
17-
# Other available options are
18-
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
12+
strict = [
13+
:doctest,
14+
:linkcheck,
15+
:parse_error,
16+
:example_block,
17+
# Other available options are
18+
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
1919
],
2020
format = Documenter.HTML(analytics = "UA-90474609-3",
2121
assets = ["assets/favicon.ico"],

lib/LinearSolvePardiso/src/LinearSolvePardiso.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ LinearSolve.needs_concrete_A(alg::PardisoJL) = true
1717

1818
# TODO schur complement functionality
1919

20-
function LinearSolve.init_cacheval(alg::PardisoJL, A, b, u, Pl, Pr, maxiters, abstol,
21-
reltol, verbose)
20+
function LinearSolve.init_cacheval(alg::PardisoJL, A, b, u, Pl, Pr, maxiters::Int, abstol,
21+
reltol, verbose::Bool,
22+
assumptions::LinearSolve.OperatorAssumptions)
2223
@unpack nprocs, solver_type, matrix_type, iparm, dparm = alg
2324
A = convert(AbstractMatrix, A)
2425

src/common.jl

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
struct LinearCache{TA, Tb, Tu, Tp, Talg, Tc, Tl, Tr, Ttol}
1+
struct OperatorAssumptions{issquare} end
2+
function OperatorAssumptions(issquare = nothing)
3+
OperatorAssumptions{_unwrap_val(issquare)}()
4+
end
5+
issquare(::OperatorAssumptions{issq}) where {issq} = issq
6+
7+
_unwrap_val(::Val{B}) where {B} = B
8+
_unwrap_val(B::Nothing) = Nothing
9+
_unwrap_val(B::Bool) = B
10+
11+
struct LinearCache{TA, Tb, Tu, Tp, Talg, Tc, Tl, Tr, Ttol, issquare}
212
A::TA
313
b::Tb
414
u::Tu
@@ -12,6 +22,7 @@ struct LinearCache{TA, Tb, Tu, Tp, Talg, Tc, Tl, Tr, Ttol}
1222
reltol::Ttol
1323
maxiters::Int
1424
verbose::Bool
25+
assumptions::OperatorAssumptions{issquare}
1526
end
1627

1728
"""
@@ -82,10 +93,11 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
8293
alias_A = false, alias_b = false,
8394
abstol = default_tol(eltype(prob.A)),
8495
reltol = default_tol(eltype(prob.A)),
85-
maxiters = length(prob.b),
86-
verbose = false,
96+
maxiters::Int = length(prob.b),
97+
verbose::Bool = false,
8798
Pl = Identity(),
8899
Pr = Identity(),
100+
assumptions = OperatorAssumptions(),
89101
kwargs...)
90102
@unpack A, b, u0, p = prob
91103

@@ -96,7 +108,8 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
96108
fill!(u0, false)
97109
end
98110

99-
cacheval = init_cacheval(alg, A, b, u0, Pl, Pr, maxiters, abstol, reltol, verbose)
111+
cacheval = init_cacheval(alg, A, b, u0, Pl, Pr, maxiters, abstol, reltol, verbose,
112+
assumptions)
100113
isfresh = true
101114
Tc = typeof(cacheval)
102115

@@ -112,7 +125,8 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
112125
Tc,
113126
typeof(Pl),
114127
typeof(Pr),
115-
typeof(reltol)
128+
typeof(reltol),
129+
issquare(assumptions)
116130
}(A,
117131
b,
118132
u0,
@@ -125,7 +139,8 @@ function SciMLBase.init(prob::LinearProblem, alg::Union{SciMLLinearSolveAlgorith
125139
abstol,
126140
reltol,
127141
maxiters,
128-
verbose)
142+
verbose,
143+
assumptions)
129144
return cache
130145
end
131146

0 commit comments

Comments
 (0)