@@ -277,6 +277,16 @@ function generate_tgrad(
277277 expression, wrap_gfw, (2 , 3 , is_split (sys)), res; eval_expression, eval_module)
278278end
279279
280+ """
281+ $(TYPEDSIGNATURES)
282+
283+ Return an array of symbolic hessians corresponding to the equations of the system.
284+
285+ # Keyword Arguments
286+
287+ - `sparse`: Controls whether the symbolic hessians are sparse matrices
288+ - `simplify`: Forwarded to `Symbolics.hessian`
289+ """
280290function calculate_hessian (sys:: System ; simplify = false , sparse = false )
281291 rhs = [eq. rhs - eq. lhs for eq in full_equations (sys)]
282292 dvs = unknowns (sys)
@@ -484,6 +494,17 @@ function W_sparsity(sys::System)
484494 jac_sparsity .| M_sparsity
485495end
486496
497+ """
498+ $(TYPEDSIGNATURES)
499+
500+ Return the matrix to use as the jacobian prototype given the W-sparsity matrix of the
501+ system. This is not the same as the jacobian sparsity pattern.
502+
503+ # Keyword arguments
504+
505+ - `u0`: The `u0` vector for the problem.
506+ - `sparse`: The prototype is `nothing` for non-sparse matrices.
507+ """
487508function calculate_W_prototype (W_sparsity; u0 = nothing , sparse = false )
488509 sparse || return nothing
489510 uElType = u0 === nothing ? Float64 : eltype (u0)
@@ -599,6 +620,12 @@ function generate_cost(sys::System; expression = Val{true}, wrap_gfw = Val{false
599620 expression, wrap_gfw, (2 , nargs, is_split (sys)), res; eval_expression, eval_module)
600621end
601622
623+ """
624+ $(TYPEDSIGNATURES)
625+
626+ Calculate the gradient of the consolidated cost of `sys` with respect to the unknowns.
627+ `simplify` is forwarded to `Symbolics.gradient`.
628+ """
602629function calculate_cost_gradient (sys:: System ; simplify = false )
603630 obj = cost (sys)
604631 dvs = unknowns (sys)
@@ -629,6 +656,13 @@ function generate_cost_gradient(
629656 expression, wrap_gfw, (2 , 2 , is_split (sys)), res; eval_expression, eval_module)
630657end
631658
659+ """
660+ $(TYPEDSIGNATURES)
661+
662+ Calculate the hessian of the consolidated cost of `sys` with respect to the unknowns.
663+ `simplify` is forwarded to `Symbolics.hessian`. `sparse` controls whether a sparse
664+ matrix is returned.
665+ """
632666function calculate_cost_hessian (sys:: System ; sparse = false , simplify = false )
633667 obj = cost (sys)
634668 dvs = unknowns (sys)
0 commit comments