1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sensitivity/TSSetIHessianProduct.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>TSSetIHessianProduct</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.14.5 2021-03-03</b></div>
<div id="bugreport" align=right><a href="mailto:petsc-maint@mcs.anl.gov?subject=Typo or Error in Documentation &body=Please describe the typo or error in the documentation: petsc-3.14.5 v3.14.5 docs/manualpages/Sensitivity/TSSetIHessianProduct.html "><small>Report Typos and Errors</small></a></div>
<A NAME="TSSetIHessianProduct"><H1>TSSetIHessianProduct</H1></A>
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.
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
#include "petscts.h"
<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> <A HREF="../Sensitivity/TSSetIHessianProduct.html#TSSetIHessianProduct">TSSetIHessianProduct</A>(<A HREF="../TS/TS.html#TS">TS</A> ts,<A HREF="../Vec/Vec.html#Vec">Vec</A> *ihp1,<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> (*ihessianproductfunc1)(<A HREF="../TS/TS.html#TS">TS</A>,<A HREF="../Sys/PetscReal.html#PetscReal">PetscReal</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,void*),
<A HREF="../Vec/Vec.html#Vec">Vec</A> *ihp2,<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> (*ihessianproductfunc2)(<A HREF="../TS/TS.html#TS">TS</A>,<A HREF="../Sys/PetscReal.html#PetscReal">PetscReal</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,void*),
<A HREF="../Vec/Vec.html#Vec">Vec</A> *ihp3,<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> (*ihessianproductfunc3)(<A HREF="../TS/TS.html#TS">TS</A>,<A HREF="../Sys/PetscReal.html#PetscReal">PetscReal</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,void*),
<A HREF="../Vec/Vec.html#Vec">Vec</A> *ihp4,<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> (*ihessianproductfunc4)(<A HREF="../TS/TS.html#TS">TS</A>,<A HREF="../Sys/PetscReal.html#PetscReal">PetscReal</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,<A HREF="../Vec/Vec.html#Vec">Vec</A>,<A HREF="../Vec/Vec.html#Vec">Vec</A>*,void*),
void *ctx)
</PRE>
Logically Collective on <A HREF="../TS/TS.html#TS">TS</A>
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ts </B></TD><TD>- <A HREF="../TS/TS.html#TS">TS</A> context obtained from <A HREF="../TS/TSCreate.html#TSCreate">TSCreate</A>()
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ihp1 </B></TD><TD>- an array of vectors storing the result of vector-Hessian-vector product for F_UU
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>hessianproductfunc1 </B></TD><TD>- vector-Hessian-vector product function for F_UU
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ihp2 </B></TD><TD>- an array of vectors storing the result of vector-Hessian-vector product for F_UP
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>hessianproductfunc2 </B></TD><TD>- vector-Hessian-vector product function for F_UP
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ihp3 </B></TD><TD>- an array of vectors storing the result of vector-Hessian-vector product for F_PU
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>hessianproductfunc3 </B></TD><TD>- vector-Hessian-vector product function for F_PU
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ihp4 </B></TD><TD>- an array of vectors storing the result of vector-Hessian-vector product for F_PP
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>hessianproductfunc4 </B></TD><TD>- vector-Hessian-vector product function for F_PP
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Calling sequence of ihessianproductfunc</FONT></H3>
<pre>
ihessianproductfunc (<A HREF="../TS/TS.html#TS">TS</A> ts,<A HREF="../Sys/PetscReal.html#PetscReal">PetscReal</A> t,<A HREF="../Vec/Vec.html#Vec">Vec</A> U,<A HREF="../Vec/Vec.html#Vec">Vec</A> *Vl,<A HREF="../Vec/Vec.html#Vec">Vec</A> Vr,<A HREF="../Vec/Vec.html#Vec">Vec</A> *VHV,void *ctx);
</pre>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>t </B></TD><TD>- current timestep
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>U </B></TD><TD>- input vector (current ODE solution)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>Vl </B></TD><TD>- an array of input vectors to be left-multiplied with the Hessian
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>Vr </B></TD><TD>- input vector to be right-multiplied with the Hessian
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>VHV </B></TD><TD>- an array of output vectors for vector-Hessian-vector product
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ctx </B></TD><TD>- [optional] user-defined function context
</TD></TR></TABLE>
<P>
<P>
<H3><FONT COLOR="#CC3333">Notes</FONT></H3>
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.
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<BR><P><B></B><H3><FONT COLOR="#CC3333">Level</FONT></H3>intermediate<BR>
<H3><FONT COLOR="#CC3333">Location</FONT></H3>
</B><A HREF="../../../src/ts/interface/sensitivity/tssen.c.html#TSSetIHessianProduct">src/ts/interface/sensitivity/tssen.c</A>
<P><H3><FONT COLOR="#CC3333">Examples</FONT></H3>
<A HREF="../../../src/ts/tutorials/ex20opt_p.c.html">src/ts/tutorials/ex20opt_p.c.html</A><BR>
<A HREF="../../../src/ts/tutorials/ex20opt_ic.c.html">src/ts/tutorials/ex20opt_ic.c.html</A><BR>
<BR><A HREF="./index.html">Index of all Sensitivity routines</A>
<BR><A HREF="../../index.html">Table of Contents for all manual pages</A>
<BR><A HREF="../singleindex.html">Index of all manual pages</A>
</BODY></HTML>
|