@@ -317,18 +317,18 @@ end
317317Return a function to evaluate ``∂J_a/∂ϵ_{ln}`` for a pulse value running cost.
318318
319319```julia
320- grad_J_a! = make_grad_J_a(
320+ grad_J_a = make_grad_J_a(
321321 J_a,
322322 tlist;
323323 mode=:any,
324324 automatic=:default,
325325)
326326```
327327
328- returns a function so that `grad_J_a!( ∇J_a, pulsevals, tlist)` sets
329- ``∂J_a/∂ϵ_{ln}`` as the elements of the (vectorized) `∇J_a`. The function `J_a`
330- must have the interface `J_a(pulsevals, tlist)`, see, e.g. ,
331- ` J_a_fluence`.
328+ returns a function so that `∇J_a = grad_J_a( pulsevals, tlist)` sets
329+ that retrurns a vector `∇J_a` containing the vectorized elements
330+ ``∂J_a/∂ϵ_{ln}``. The function `J_a` must have the interface `J_a(pulsevals,
331+ tlist)`, see, e.g., [` J_a_fluence`](@ref) .
332332
333333The parameters `mode` and `automatic` are handled as in [`make_chi`](@ref),
334334where `mode` is one of `:any`, `:analytic`, `:automatic`, and `automatic` is
@@ -341,10 +341,11 @@ refers to the framework set with `QuantumControl.set_default_ad_framework`.
341341 new `J_a` function, define a new method `make_analytic_grad_J_a` like so:
342342
343343 ```julia
344- make_analytic_grad_J_a(::typeof(J_a_fluence), tlist) = grad_J_a_fluence!
344+ make_analytic_grad_J_a(::typeof(J_a_fluence), tlist) = grad_J_a_fluence
345345 ```
346346
347- which links `make_grad_J_a` for `J_a_fluence` to `grad_J_a_fluence!`.
347+ which links `make_grad_J_a` for [`J_a_fluence`](@ref) to
348+ [`grad_J_a_fluence`](@ref).
348349"""
349350function make_grad_J_a (J_a, tlist; mode= :any , automatic= :default )
350351 if mode == :any
@@ -890,19 +891,20 @@ end
890891""" Analytic derivative for [`J_a_fluence`](@ref).
891892
892893```julia
893- grad_J_a_fluence!( ∇J_a, pulsevals, tlist)
894+ ∇J_a = grad_J_a_fluence( pulsevals, tlist)
894895```
895896
896- sets the (vectorized) elements of `∇J_a` to ``2 ϵ_{nl} dt``, where
897- ``ϵ_{nl}`` are the (vectorized) elements of `pulsevals` and ``dt`` is the time
898- step, taken from the first time interval of `tlist` and assumed to be uniform.
897+ returns the `∇J_a`, which contains the (vectorized) elements ``2 ϵ_{nl} dt``,
898+ where ``ϵ_{nl}`` are the (vectorized) elements of `pulsevals` and ``dt`` is the
899+ time step, taken from the first time interval of `tlist` and assumed to be
900+ uniform.
899901"""
900- function grad_J_a_fluence! (∇J_a, pulsevals, tlist)
902+ function grad_J_a_fluence ( pulsevals, tlist)
901903 dt = tlist[begin + 1 ] - tlist[begin ]
902- axpy! (2 * dt, pulsevals, ∇J_a)
904+ return (2 * dt) * pulsevals
903905end
904906
905907
906- make_analytic_grad_J_a (:: typeof (J_a_fluence), tlist) = grad_J_a_fluence!
908+ make_analytic_grad_J_a (:: typeof (J_a_fluence), tlist) = grad_J_a_fluence
907909
908910end
0 commit comments