@@ -7,8 +7,8 @@ Given a Linear Problem ``A x = b`` computes the sensitivities for ``A`` and ``b`
77
88```math
99\b egin{align}
10- A^T \l ambda &= \p artial x \\
11- \p artial A &= -\l ambda x^T \\
10+ A' \l ambda &= \p artial x \\
11+ \p artial A &= -\l ambda x' \\
1212\p artial b &= \l ambda
1313\e nd{align}
1414```
@@ -20,7 +20,7 @@ For more details, check [these notes](https://math.mit.edu/~stevenj/18.336/adjoi
2020Note that in most cases, it makes sense to use the same linear solver for the adjoint as the
2121forward solve (this is done by keeping the linsolve as `missing`). For example, if the
2222forward solve was performed via a Factorization, then we can reuse the factorization for the
23- adjoint solve. However, for specific structured matrices if ``A^T `` is known to have a
23+ adjoint solve. However, for specific structured matrices if ``A' `` is known to have a
2424specific structure distinct from ``A`` then passing in a `linsolve` will be more efficient.
2525"""
2626@kwdef struct LinearSolveAdjoint{L} < :
@@ -62,21 +62,21 @@ function CRC.rrule(::typeof(SciMLBase.solve), prob::LinearProblem,
6262 elseif cache. cacheval isa Tuple && cache. cacheval[1 ] isa Factorization
6363 first (cache. cacheval)' \ ∂u
6464 elseif alg isa AbstractKrylovSubspaceMethod
65- invprob = LinearProblem (transpose (cache. A), ∂u)
65+ invprob = LinearProblem (adjoint (cache. A), ∂u)
6666 solve (invprob, alg; cache. abstol, cache. reltol, cache. verbose). u
6767 elseif alg isa DefaultLinearSolver
6868 LinearSolve. defaultalg_adjoint_eval (cache, ∂u)
6969 else
70- invprob = LinearProblem (transpose (A_), ∂u) # We cached `A`
70+ invprob = LinearProblem (adjoint (A_), ∂u) # We cached `A`
7171 solve (invprob, alg; cache. abstol, cache. reltol, cache. verbose). u
7272 end
7373 else
74- invprob = LinearProblem (transpose (A_), ∂u) # We cached `A`
74+ invprob = LinearProblem (adjoint (A_), ∂u) # We cached `A`
7575 λ = solve (
7676 invprob, sensealg. linsolve; cache. abstol, cache. reltol, cache. verbose). u
7777 end
7878
79- tu = transpose (sol. u)
79+ tu = adjoint (sol. u)
8080 ∂A = BroadcastArray (@~ .- (λ .* tu))
8181 ∂b = λ
8282 ∂prob = LinearProblem (∂A, ∂b, ∂∅)
0 commit comments