Skip to content

Commit 5f221eb

Browse files
committed
Update documentation regarding alias behavior
This patch documents that `alias_A` and `alias_b` may depend on whether the algorithm is known not to modify `A` or `b`. As a minimal first change, this patch updates the default value for `alg::AbstractKrylovSubspaceMethod` from `false` to `true`.
1 parent 9718ea2 commit 5f221eb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/src/basics/common_solver_opts.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ The following are the options these algorithms take, along with their defaults.
77

88
## General Controls
99

10-
- `alias_A`: Whether to alias the matrix `A` or use a copy by default. When true,
10+
- `alias_A::Bool`: Whether to alias the matrix `A` or use a copy by default. When `true`,
1111
algorithms like LU-factorization can be faster by reusing the memory via `lu!`,
12-
but care must be taken as the original input will be modified. Default is `false`.
13-
- `alias_b`: Whether to alias the matrix `b` or use a copy by default. When true,
12+
but care must be taken as the original input will be modified. Default is `true` if the
13+
algorithm is known not to modify `A`, otherwise is `false`.
14+
- `alias_b::Bool`: Whether to alias the matrix `b` or use a copy by default. When `true`,
1415
algorithms can write and change `b` upon usage. Care must be taken as the
15-
original input will be modified. Default is `false`.
16+
original input will be modified. Default is `true` if the algorithm is known not to
17+
modify `b`, otherwise `false`.
1618
- `verbose`: Whether to print extra information. Defaults to `false`.
1719
- `assumptions`: Sets the assumptions of the operator in order to effect the default
1820
choice algorithm. See the [Operator Assumptions page for more details](@ref assumptions).

src/common.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ default_tol(::Type{Any}) = 0
107107
default_alias_A(::Any, ::Any, ::Any) = false
108108
default_alias_b(::Any, ::Any, ::Any) = false
109109

110+
# Non-destructive algorithms default to true
111+
default_alias_A(::AbstractKrylovSubspaceMethod, ::Any, ::Any) = true
112+
default_alias_b(::AbstractKrylovSubspaceMethod, ::Any, ::Any) = true
113+
110114
function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm,
111115
args...;
112116
alias_A = default_alias_A(alg, prob.A, prob.b),

0 commit comments

Comments
 (0)