From 5cad655e2cb30616f958594298e1cc4a29bde5d0 Mon Sep 17 00:00:00 2001 From: Maxime Bouyges Date: Mon, 12 Jan 2026 16:23:38 +0100 Subject: [PATCH 1/5] wip --- src/settings.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/settings.jl b/src/settings.jl index 3637e17..5b952db 100644 --- a/src/settings.jl +++ b/src/settings.jl @@ -10,6 +10,17 @@ Specify that linear systems `Ax = b` should be solved with a direct method. !!! warning Can only be used when the `solver` and the `conditions` both output an `AbstractVector`. + Additionnaly, this solver requires a [`MatrixRepresentation`](@ref) of the matrix `A`. To do so, + use the `representation` keyword of the [`ImplicitFunction`](@ref) constructor : + ``` + f = ImplicitFunction( + forward, + conditions; + solver = DirectLinearSolver(), + representation = MatrixRepresentation() + ) + ``` + # See also - [`ImplicitFunction`](@ref) From 68c926df11425d3cd14e58bbf55b8a8841cb04ae Mon Sep 17 00:00:00 2001 From: Maxime Bouyges Date: Mon, 19 Jan 2026 10:08:35 +0100 Subject: [PATCH 2/5] add doc to FAQ --- docs/src/faq.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/src/faq.md b/docs/src/faq.md index 0322055..e8169b4 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -102,3 +102,15 @@ Packages such as [Memoize.jl](https://github.com/JuliaCollections/Memoize.jl) an using Memoize @memoize Dict forward(x, args...; kwargs...) = y, z ``` + +### Linear solver selection + +Differentiating your implicit function requires to solve a linear system. By default, an iterative solver (see [`IterativeSolver`](@ref)) combined with a matrix-free representation of the jacobian (see [`OperatorRepresentation`](@ref)) is used. You can change the linear solver using the `linear_solver` keyword argument of the `ImplicitFunction` constructor, choosing between: + +- [`IterativeSolver`](@ref); +- [`IterativeLeastSquaresSolver`](@ref); +- [`DirectLinearSolver`](@ref). + +Keyword arguments can be passed to the constructors of `IterativeSolver` and `IterativeLeastSquaresSolver`, they will be forwarded to the `KrylovKit.linsolve` and `KrylovKit.lssolve` functions, respectively. + +Note that for the `DirectLinearSolver`, you must switch to a [`MatrixRepresentation`](@ref) using the `representation` argument : `ImplicitFunction(forward, conditions; linear_solver = DirectLinearSolver(), representation = MatrixRepresentation())`. From bbaac01ffb31b574f8471b10dfb6acdfb05d6406 Mon Sep 17 00:00:00 2001 From: mbouyges Date: Tue, 20 Jan 2026 08:36:40 +0100 Subject: [PATCH 3/5] fix IterativeLinearSolver name --- docs/src/faq.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/faq.md b/docs/src/faq.md index e8169b4..ea8c875 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -105,12 +105,12 @@ using Memoize ### Linear solver selection -Differentiating your implicit function requires to solve a linear system. By default, an iterative solver (see [`IterativeSolver`](@ref)) combined with a matrix-free representation of the jacobian (see [`OperatorRepresentation`](@ref)) is used. You can change the linear solver using the `linear_solver` keyword argument of the `ImplicitFunction` constructor, choosing between: +Differentiating your implicit function requires to solve a linear system. By default, an iterative solver (see [`IterativeLinearSolver`](@ref)) combined with a matrix-free representation of the jacobian (see [`OperatorRepresentation`](@ref)) is used. You can change the linear solver using the `linear_solver` keyword argument of the `ImplicitFunction` constructor, choosing between: -- [`IterativeSolver`](@ref); +- [`IterativeLinearSolver`](@ref); - [`IterativeLeastSquaresSolver`](@ref); - [`DirectLinearSolver`](@ref). -Keyword arguments can be passed to the constructors of `IterativeSolver` and `IterativeLeastSquaresSolver`, they will be forwarded to the `KrylovKit.linsolve` and `KrylovKit.lssolve` functions, respectively. +Keyword arguments can be passed to the constructors of `IterativeLinearSolver` and `IterativeLeastSquaresSolver`, they will be forwarded to the `KrylovKit.linsolve` and `KrylovKit.lssolve` functions, respectively. Note that for the `DirectLinearSolver`, you must switch to a [`MatrixRepresentation`](@ref) using the `representation` argument : `ImplicitFunction(forward, conditions; linear_solver = DirectLinearSolver(), representation = MatrixRepresentation())`. From 63a7452a98fc4a3cfe7de8f4230165c396fdb72b Mon Sep 17 00:00:00 2001 From: mbouyges Date: Tue, 20 Jan 2026 08:43:15 +0100 Subject: [PATCH 4/5] Remove backticks --- src/settings.jl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/settings.jl b/src/settings.jl index 5b952db..5e1d4ed 100644 --- a/src/settings.jl +++ b/src/settings.jl @@ -12,14 +12,13 @@ Specify that linear systems `Ax = b` should be solved with a direct method. Additionnaly, this solver requires a [`MatrixRepresentation`](@ref) of the matrix `A`. To do so, use the `representation` keyword of the [`ImplicitFunction`](@ref) constructor : - ``` - f = ImplicitFunction( - forward, - conditions; - solver = DirectLinearSolver(), - representation = MatrixRepresentation() - ) - ``` + + f = ImplicitFunction( + forward, + conditions; + solver = DirectLinearSolver(), + representation = MatrixRepresentation() + ) # See also From d355c790cb87d707e667444d3416371da736c389 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Tue, 20 Jan 2026 10:56:36 +0100 Subject: [PATCH 5/5] Apply suggestions from code review --- docs/src/faq.md | 5 ++++- src/settings.jl | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/src/faq.md b/docs/src/faq.md index ea8c875..0fa74c4 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -111,6 +111,9 @@ Differentiating your implicit function requires to solve a linear system. By def - [`IterativeLeastSquaresSolver`](@ref); - [`DirectLinearSolver`](@ref). -Keyword arguments can be passed to the constructors of `IterativeLinearSolver` and `IterativeLeastSquaresSolver`, they will be forwarded to the `KrylovKit.linsolve` and `KrylovKit.lssolve` functions, respectively. +Keyword arguments can be passed to the constructors of `IterativeLinearSolver` and `IterativeLeastSquaresSolver`, they will be forwarded to the solver that is currently being used. + +!!! warning + The specific choice of solver is not part of the public API, and may thus change without a breaking release. If you rely on keyword arguments, please freeze the exact version of ImplicitDifferentiation in your `Project.toml`. Note that for the `DirectLinearSolver`, you must switch to a [`MatrixRepresentation`](@ref) using the `representation` argument : `ImplicitFunction(forward, conditions; linear_solver = DirectLinearSolver(), representation = MatrixRepresentation())`. diff --git a/src/settings.jl b/src/settings.jl index 5e1d4ed..2b583d8 100644 --- a/src/settings.jl +++ b/src/settings.jl @@ -10,7 +10,7 @@ Specify that linear systems `Ax = b` should be solved with a direct method. !!! warning Can only be used when the `solver` and the `conditions` both output an `AbstractVector`. - Additionnaly, this solver requires a [`MatrixRepresentation`](@ref) of the matrix `A`. To do so, + Additionally, this solver requires a [`MatrixRepresentation`](@ref) of the matrix `A`. To do so, use the `representation` keyword of the [`ImplicitFunction`](@ref) constructor : f = ImplicitFunction(