TSSetIHessianProduct#
Sets the function that computes the vector-Hessian-vector product. The Hessian is the second-order derivative of F (IFunction) w.r.t. the state variable.
Synopsis#
#include <petscts.h>
PetscErrorCode TSSetIHessianProduct(TS ts, Vec *ihp1, PetscErrorCode (*ihessianproductfunc1)(TS ts, PetscReal t, Vec U, Vec *Vl, Vec Vr, Vec *VHV, void *ctx), Vec *ihp2, PetscErrorCode (*ihessianproductfunc2)(TS, PetscReal, Vec, Vec *, Vec, Vec *, void *), Vec *ihp3, PetscErrorCode (*ihessianproductfunc3)(TS, PetscReal, Vec, Vec *, Vec, Vec *, void *), Vec *ihp4, PetscErrorCode (*ihessianproductfunc4)(TS, PetscReal, Vec, Vec *, Vec, Vec *, void *), void *ctx)
Logically Collective
Input Parameters#
ihp1 - an array of vectors storing the result of vector-Hessian-vector product for F_UU
hessianproductfunc1 - vector-Hessian-vector product function for F_UU
ihp2 - an array of vectors storing the result of vector-Hessian-vector product for F_UP
hessianproductfunc2 - vector-Hessian-vector product function for F_UP
ihp3 - an array of vectors storing the result of vector-Hessian-vector product for F_PU
hessianproductfunc3 - vector-Hessian-vector product function for F_PU
ihp4 - an array of vectors storing the result of vector-Hessian-vector product for F_PP
hessianproductfunc4 - vector-Hessian-vector product function for F_PP
Calling sequence of ihessianproductfunc1
#
ts - the
TS
context
t - current timestep
U - input vector (current ODE solution)
Vl - an array of input vectors to be left-multiplied with the Hessian
Vr - input vector to be right-multiplied with the Hessian
VHV - an array of output vectors for vector-Hessian-vector product
ctx - [optional] user-defined function context
Notes#
All other functions have the same calling sequence as rhhessianproductfunc1
, so their
descriptions are omitted for brevity.
The first Hessian function and the working array are required. As an example to implement the callback functions, the second callback function calculates the vector-Hessian-vector product \( Vl_n^T*F_UP*Vr where the vector Vl_n (n-th element in the array Vl) and Vr are of size N and M respectively, and the Hessian F_UP is of size N x N x M. Each entry of F_UP corresponds to the derivative \) F_UP[i][j][k] = \frac{\partial^2 F[i]}{\partial U[j] \partial P[k]}. The result of the vector-Hessian-vector product for Vl_n needs to be stored in vector VHV_n with the j-th entry being $ VHV_n[j] = \sum_i \sum_k {Vl_n[i] * F_UP[i][j][k] * Vr[k]} If the cost function is a scalar, there will be only one vector in Vl and VHV.
See Also#
Level#
intermediate
Location#
Examples#
src/ts/tutorials/ex20opt_ic.c
src/ts/tutorials/ex20opt_p.c
Index of all Sensitivity routines
Table of Contents for all manual pages
Index of all manual pages