Skip to content

Commit a1fedb8

Browse files
format
1 parent c35900c commit a1fedb8

25 files changed

+493
-487
lines changed

docs/make.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ DocMeta.setdocmeta!(LinearSolve, :DocTestSetup, :(using LinearSolve); recursive
99
include("pages.jl")
1010

1111
makedocs(sitename = "LinearSolve.jl",
12-
authors = "Chris Rackauckas",
13-
modules = [LinearSolve, LinearSolve.SciMLBase],
14-
clean = true, doctest = false, linkcheck = true,
15-
strict = [
16-
:doctest,
17-
:linkcheck,
18-
:parse_error,
19-
:example_block,
20-
# Other available options are
21-
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
22-
],
23-
format = Documenter.HTML(assets = ["assets/favicon.ico"],
24-
canonical = "https://docs.sciml.ai/LinearSolve/stable/"),
25-
pages = pages)
12+
authors = "Chris Rackauckas",
13+
modules = [LinearSolve, LinearSolve.SciMLBase],
14+
clean = true, doctest = false, linkcheck = true,
15+
strict = [
16+
:doctest,
17+
:linkcheck,
18+
:parse_error,
19+
:example_block,
20+
# Other available options are
21+
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
22+
],
23+
format = Documenter.HTML(assets = ["assets/favicon.ico"],
24+
canonical = "https://docs.sciml.ai/LinearSolve/stable/"),
25+
pages = pages)
2626

2727
deploydocs(;
28-
repo = "github.com/SciML/LinearSolve.jl",
29-
push_preview = true)
28+
repo = "github.com/SciML/LinearSolve.jl",
29+
push_preview = true)

docs/pages.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
pages = ["index.md",
44
"Tutorials" => Any["tutorials/linear.md"
5-
"tutorials/caching_interface.md"],
5+
"tutorials/caching_interface.md"],
66
"Basics" => Any["basics/LinearProblem.md",
7-
"basics/common_solver_opts.md",
8-
"basics/OperatorAssumptions.md",
9-
"basics/Preconditioners.md",
10-
"basics/FAQ.md"],
7+
"basics/common_solver_opts.md",
8+
"basics/OperatorAssumptions.md",
9+
"basics/Preconditioners.md",
10+
"basics/FAQ.md"],
1111
"Solvers" => Any["solvers/solvers.md"],
1212
"Advanced" => Any["advanced/developing.md"
13-
"advanced/custom.md"],
13+
"advanced/custom.md"],
1414
"Release Notes" => "release_notes.md",
1515
]

docs/src/advanced/developing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ basic machinery. A simplified version is:
1818
struct MyLUFactorization{P} <: SciMLBase.AbstractLinearAlgorithm end
1919

2020
function init_cacheval(alg::MyLUFactorization, A, b, u, Pl, Pr, maxiters, abstol, reltol,
21-
verbose)
21+
verbose)
2222
lu!(convert(AbstractMatrix, A))
2323
end
2424

docs/src/basics/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ b = rand(n)
8080
weights = rand(n)
8181
realprec = lu(rand(n, n)) # some random preconditioner
8282
Pl = LinearSolve.ComposePreconditioner(LinearSolve.InvPreconditioner(Diagonal(weights)),
83-
realprec)
83+
realprec)
8484
Pr = Diagonal(weights)
8585
8686
prob = LinearProblem(A, b)

ext/LinearSolveCUDAExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using CUDA, LinearAlgebra, LinearSolve, SciMLBase
44
using SciMLBase: AbstractSciMLOperator
55

66
function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::CudaOffloadFactorization;
7-
kwargs...)
7+
kwargs...)
88
if cache.isfresh
99
fact = LinearSolve.do_factorization(alg, CUDA.CuArray(cache.A), cache.b, cache.u)
1010
cache = LinearSolve.set_cacheval(cache, fact)

ext/LinearSolveHYPREExt.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using LinearAlgebra
44
using HYPRE.LibHYPRE: HYPRE_Complex
55
using HYPRE: HYPRE, HYPREMatrix, HYPRESolver, HYPREVector
66
using LinearSolve: HYPREAlgorithm, LinearCache, LinearProblem, LinearSolve,
7-
OperatorAssumptions, default_tol, init_cacheval, __issquare,
8-
__conditioning
7+
OperatorAssumptions, default_tol, init_cacheval, __issquare,
8+
__conditioning
99
using SciMLBase: LinearProblem, SciMLBase
1010
using UnPack: @unpack
1111
using Setfield: @set!
@@ -21,8 +21,8 @@ mutable struct HYPRECache
2121
end
2222

2323
function LinearSolve.init_cacheval(alg::HYPREAlgorithm, A, b, u, Pl, Pr, maxiters::Int,
24-
abstol, reltol,
25-
verbose::Bool, assumptions::OperatorAssumptions)
24+
abstol, reltol,
25+
verbose::Bool, assumptions::OperatorAssumptions)
2626
return HYPRECache(nothing, nothing, nothing, nothing, true, true, true)
2727
end
2828

@@ -54,21 +54,21 @@ end
5454
# fill!(similar(b, size(A, 2)), false) since HYPREArrays are not AbstractArrays.
5555

5656
function SciMLBase.init(prob::LinearProblem, alg::HYPREAlgorithm,
57-
args...;
58-
alias_A = false, alias_b = false,
59-
# TODO: Implement eltype for HYPREMatrix in HYPRE.jl? Looks useful
60-
# even if it is not AbstractArray.
61-
abstol = default_tol(prob.A isa HYPREMatrix ? HYPRE_Complex :
62-
eltype(prob.A)),
63-
reltol = default_tol(prob.A isa HYPREMatrix ? HYPRE_Complex :
64-
eltype(prob.A)),
65-
# TODO: Implement length() for HYPREVector in HYPRE.jl?
66-
maxiters::Int = prob.b isa HYPREVector ? 1000 : length(prob.b),
67-
verbose::Bool = false,
68-
Pl = LinearAlgebra.I,
69-
Pr = LinearAlgebra.I,
70-
assumptions = OperatorAssumptions(),
71-
kwargs...)
57+
args...;
58+
alias_A = false, alias_b = false,
59+
# TODO: Implement eltype for HYPREMatrix in HYPRE.jl? Looks useful
60+
# even if it is not AbstractArray.
61+
abstol = default_tol(prob.A isa HYPREMatrix ? HYPRE_Complex :
62+
eltype(prob.A)),
63+
reltol = default_tol(prob.A isa HYPREMatrix ? HYPRE_Complex :
64+
eltype(prob.A)),
65+
# TODO: Implement length() for HYPREVector in HYPRE.jl?
66+
maxiters::Int = prob.b isa HYPREVector ? 1000 : length(prob.b),
67+
verbose::Bool = false,
68+
Pl = LinearAlgebra.I,
69+
Pr = LinearAlgebra.I,
70+
assumptions = OperatorAssumptions(),
71+
kwargs...)
7272
@unpack A, b, u0, p = prob
7373

7474
A = A isa HYPREMatrix ? A : HYPREMatrix(A)
@@ -82,23 +82,23 @@ function SciMLBase.init(prob::LinearProblem, alg::HYPREAlgorithm,
8282

8383
# Initialize internal alg cache
8484
cacheval = init_cacheval(alg, A, b, u0, Pl, Pr, maxiters, abstol, reltol, verbose,
85-
assumptions)
85+
assumptions)
8686
Tc = typeof(cacheval)
8787
isfresh = true
8888

8989
cache = LinearCache{
90-
typeof(A), typeof(b), typeof(u0), typeof(p), typeof(alg), Tc,
91-
typeof(Pl), typeof(Pr), typeof(reltol),
92-
typeof(__issquare(assumptions))
93-
}(A, b, u0, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
94-
maxiters,
95-
verbose, assumptions)
90+
typeof(A), typeof(b), typeof(u0), typeof(p), typeof(alg), Tc,
91+
typeof(Pl), typeof(Pr), typeof(reltol),
92+
typeof(__issquare(assumptions)),
93+
}(A, b, u0, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
94+
maxiters,
95+
verbose, assumptions)
9696
return cache
9797
end
9898

9999
# Solvers whose constructor requires passing the MPI communicator
100100
const COMM_SOLVERS = Union{HYPRE.BiCGSTAB, HYPRE.FlexGMRES, HYPRE.GMRES, HYPRE.ParaSails,
101-
HYPRE.PCG}
101+
HYPRE.PCG}
102102
create_solver(::Type{S}, comm) where {S <: COMM_SOLVERS} = S(comm)
103103

104104
# Solvers whose constructor should not be passed the MPI communicator
@@ -120,10 +120,10 @@ function create_solver(alg::HYPREAlgorithm, cache::LinearCache)
120120

121121
# Construct solver options
122122
solver_options = (;
123-
AbsoluteTol = cache.abstol,
124-
MaxIter = cache.maxiters,
125-
PrintLevel = Int(cache.verbose),
126-
Tol = cache.reltol)
123+
AbsoluteTol = cache.abstol,
124+
MaxIter = cache.maxiters,
125+
PrintLevel = Int(cache.verbose),
126+
Tol = cache.reltol)
127127

128128
# Preconditioner (uses Pl even though it might not be a *left* preconditioner just *a*
129129
# preconditioner)
@@ -211,16 +211,16 @@ function SciMLBase.solve!(cache::LinearCache, alg::HYPREAlgorithm, args...; kwar
211211
stats = nothing
212212

213213
ret = SciMLBase.LinearSolution{T, N, typeof(cache.u), typeof(resid), typeof(alg),
214-
typeof(cache), typeof(stats)}(cache.u, resid, alg, retc,
215-
iters, cache, stats)
214+
typeof(cache), typeof(stats)}(cache.u, resid, alg, retc,
215+
iters, cache, stats)
216216

217217
return ret
218218
end
219219

220220
# HYPREArrays are not AbstractArrays so perform some type-piracy
221221
function SciMLBase.LinearProblem(A::HYPREMatrix, b::HYPREVector,
222-
p = SciMLBase.NullParameters();
223-
u0::Union{HYPREVector, Nothing} = nothing, kwargs...)
222+
p = SciMLBase.NullParameters();
223+
u0::Union{HYPREVector, Nothing} = nothing, kwargs...)
224224
return LinearProblem{true}(A, b, p; u0 = u0, kwargs)
225225
end
226226

ext/LinearSolveIterativeSolversExt.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,76 +11,76 @@ else
1111
end
1212

1313
function LinearSolve.IterativeSolversJL(args...;
14-
generate_iterator = IterativeSolvers.gmres_iterable!,
15-
gmres_restart = 0, kwargs...)
14+
generate_iterator = IterativeSolvers.gmres_iterable!,
15+
gmres_restart = 0, kwargs...)
1616
return IterativeSolversJL(generate_iterator, gmres_restart,
17-
args, kwargs)
17+
args, kwargs)
1818
end
1919

2020
function LinearSolve.IterativeSolversJL_CG(args...; kwargs...)
2121
IterativeSolversJL(args...;
22-
generate_iterator = IterativeSolvers.cg_iterator!,
23-
kwargs...)
22+
generate_iterator = IterativeSolvers.cg_iterator!,
23+
kwargs...)
2424
end
2525
function LinearSolve.IterativeSolversJL_GMRES(args...; kwargs...)
2626
IterativeSolversJL(args...;
27-
generate_iterator = IterativeSolvers.gmres_iterable!,
28-
kwargs...)
27+
generate_iterator = IterativeSolvers.gmres_iterable!,
28+
kwargs...)
2929
end
3030
function LinearSolve.IterativeSolversJL_BICGSTAB(args...; kwargs...)
3131
IterativeSolversJL(args...;
32-
generate_iterator = IterativeSolvers.bicgstabl_iterator!,
33-
kwargs...)
32+
generate_iterator = IterativeSolvers.bicgstabl_iterator!,
33+
kwargs...)
3434
end
3535
function LinearSolve.IterativeSolversJL_MINRES(args...; kwargs...)
3636
IterativeSolversJL(args...;
37-
generate_iterator = IterativeSolvers.minres_iterable!,
38-
kwargs...)
37+
generate_iterator = IterativeSolvers.minres_iterable!,
38+
kwargs...)
3939
end
4040

4141
LinearSolve._isidentity_struct(::IterativeSolvers.Identity) = true
4242
LinearSolve.default_alias_A(::IterativeSolversJL, ::Any, ::Any) = true
4343
LinearSolve.default_alias_b(::IterativeSolversJL, ::Any, ::Any) = true
4444

4545
function LinearSolve.init_cacheval(alg::IterativeSolversJL, A, b, u, Pl, Pr, maxiters::Int,
46-
abstol,
47-
reltol,
48-
verbose::Bool, assumptions::OperatorAssumptions)
46+
abstol,
47+
reltol,
48+
verbose::Bool, assumptions::OperatorAssumptions)
4949
restart = (alg.gmres_restart == 0) ? min(20, size(A, 1)) : alg.gmres_restart
5050

5151
kwargs = (abstol = abstol, reltol = reltol, maxiter = maxiters,
52-
alg.kwargs...)
52+
alg.kwargs...)
5353

5454
iterable = if alg.generate_iterator === IterativeSolvers.cg_iterator!
5555
!LinearSolve._isidentity_struct(Pr) &&
5656
@warn "$(alg.generate_iterator) doesn't support right preconditioning"
5757
alg.generate_iterator(u, A, b, Pl;
58-
kwargs...)
58+
kwargs...)
5959
elseif alg.generate_iterator === IterativeSolvers.gmres_iterable!
6060
alg.generate_iterator(u, A, b; Pl = Pl, Pr = Pr, restart = restart,
61-
kwargs...)
61+
kwargs...)
6262
elseif alg.generate_iterator === IterativeSolvers.bicgstabl_iterator!
6363
!!LinearSolve._isidentity_struct(Pr) &&
6464
@warn "$(alg.generate_iterator) doesn't support right preconditioning"
6565
alg.generate_iterator(u, A, b, alg.args...; Pl = Pl,
66-
abstol = abstol, reltol = reltol,
67-
max_mv_products = maxiters * 2,
68-
alg.kwargs...)
66+
abstol = abstol, reltol = reltol,
67+
max_mv_products = maxiters * 2,
68+
alg.kwargs...)
6969
else # minres, qmr
7070
alg.generate_iterator(u, A, b, alg.args...;
71-
abstol = abstol, reltol = reltol, maxiter = maxiters,
72-
alg.kwargs...)
71+
abstol = abstol, reltol = reltol, maxiter = maxiters,
72+
alg.kwargs...)
7373
end
7474
return iterable
7575
end
7676

7777
function SciMLBase.solve!(cache::LinearCache, alg::IterativeSolversJL; kwargs...)
7878
if cache.isfresh || !(typeof(alg) <: IterativeSolvers.GMRESIterable)
7979
solver = LinearSolve.init_cacheval(alg, cache.A, cache.b, cache.u, cache.Pl,
80-
cache.Pr,
81-
cache.maxiters, cache.abstol, cache.reltol,
82-
cache.verbose,
83-
cache.assumptions)
80+
cache.Pr,
81+
cache.maxiters, cache.abstol, cache.reltol,
82+
cache.verbose,
83+
cache.assumptions)
8484
cache.cacheval = solver
8585
cache.isfresh = false
8686
end
@@ -111,7 +111,7 @@ function purge_history!(iter::IterativeSolvers.GMRESIterable, x, b)
111111
iter.b = b
112112

113113
iter.residual.current = IterativeSolvers.init!(iter.arnoldi, iter.x, iter.b, iter.Pl,
114-
iter.Ax, initially_zero = true)
114+
iter.Ax, initially_zero = true)
115115
IterativeSolvers.init_residual!(iter.residual, iter.residual.current)
116116
iter.β = iter.residual.current
117117
nothing

ext/LinearSolveKrylovKitExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using LinearSolve, KrylovKit, LinearAlgebra
44
using LinearSolve: LinearCache
55

66
function LinearSolve.KrylovKitJL(args...;
7-
KrylovAlg = KrylovKit.GMRES, gmres_restart = 0,
8-
kwargs...)
7+
KrylovAlg = KrylovKit.GMRES, gmres_restart = 0,
8+
kwargs...)
99
return KrylovKitJL(KrylovAlg, gmres_restart, args, kwargs)
1010
end
1111

@@ -28,7 +28,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::KrylovKitJL; kwargs...)
2828
krylovdim = (alg.gmres_restart == 0) ? min(20, size(cache.A, 1)) : alg.gmres_restart
2929

3030
kwargs = (atol = atol, rtol = rtol, maxiter = maxiter, verbosity = verbosity,
31-
krylovdim = krylovdim, alg.kwargs...)
31+
krylovdim = krylovdim, alg.kwargs...)
3232

3333
x, info = KrylovKit.linsolve(cache.A, cache.b, cache.u; kwargs...)
3434

@@ -37,7 +37,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::KrylovKitJL; kwargs...)
3737
retcode = info.converged == 1 ? ReturnCode.Default : ReturnCode.ConvergenceFailure
3838
iters = info.numiter
3939
return SciMLBase.build_linear_solution(alg, cache.u, resid, cache; retcode = retcode,
40-
iters = iters)
40+
iters = iters)
4141
end
4242

4343
end

ext/LinearSolvePardisoExt.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ LinearSolve.needs_concrete_A(alg::PardisoJL) = true
1212
# TODO schur complement functionality
1313

1414
function LinearSolve.init_cacheval(alg::PardisoJL,
15-
A,
16-
b,
17-
u,
18-
Pl,
19-
Pr,
20-
maxiters::Int,
21-
abstol,
22-
reltol,
23-
verbose::Bool,
24-
assumptions::LinearSolve.OperatorAssumptions)
15+
A,
16+
b,
17+
u,
18+
Pl,
19+
Pr,
20+
maxiters::Int,
21+
abstol,
22+
reltol,
23+
verbose::Bool,
24+
assumptions::LinearSolve.OperatorAssumptions)
2525
@unpack nprocs, solver_type, matrix_type, iparm, dparm = alg
2626
A = convert(AbstractMatrix, A)
2727

@@ -93,9 +93,9 @@ function LinearSolve.init_cacheval(alg::PardisoJL,
9393
end
9494

9595
Pardiso.pardiso(solver,
96-
u,
97-
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A), nonzeros(A)),
98-
b)
96+
u,
97+
SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A), nonzeros(A)),
98+
b)
9999

100100
return solver
101101
end

0 commit comments

Comments
 (0)