Options for drawing the result, using coloring instead of dense differencing, and thresholding using rtol and atol to avoid false positives. IIRC, the reason I added all of those variants was because I was given some Jacobian code that was only incorrect when something occurred at a boundary, and was not always obvious for small sizes. In any case, drawing the difference is quite handy.<div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Dec 13, 2012 at 3:29 PM, Peter Brune <span dir="ltr"><<a href="mailto:prbrune@gmail.com" target="_blank">prbrune@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Reaction after looking at Barry's changeset -- yeah this is great.  Jed, does -compare_explicit_* do anything that's missing here?<span class="HOEnZb"><font color="#888888"><br><br>- Peter</font></span><div class="HOEnZb">
<div class="h5"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 13, 2012 at 5:22 PM, Peter Brune <span dir="ltr"><<a href="mailto:prbrune@gmail.com" target="_blank">prbrune@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Thu, Dec 13, 2012 at 5:10 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br>
On Dec 13, 2012, at 5:04 PM, Peter Brune <<a href="mailto:prbrune@gmail.com" target="_blank">prbrune@gmail.com</a>> wrote:<br>
<br>
> Dangit Barry!  I already started a patch moving all Jed's -snes_compare_* garbage in SNESComputeJacobian() over to a SNESJacobianMonitor registration type deal where it has functions you can register to run after computing the Jacobian.  This will allow you to do all sorts of nice comparisons.<br>



<br>
</div>  Dang it we don't need yet another registration thingy, I used the SNESSetUpdate() hook.<br> 
<br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  Actually I don't mind if you do something better and remove mine (it is the story of my life) but don't remove mine until yours produces as pretty an output and has good names for the options and yes<br>
snes_compare_explicit is a terrible name. At least put jacobian in the option so I have some clue that it has something to do with the jacobian!<br>
<span><font color="#888888"><br></font></span></blockquote></div><div><br>I agree, and this seems like a fine place for it to happen.  I'll have to look at exactly what you did, but you could save a Jacobian computation if you put it after the user Jacobian has been computed, which is why I was putting it as hooks to be run at the end of SNESComputeJacobian().<br>


<br>I want similar facilities for the objectives as well.   There's already an FD test objective in place (used by SNESTEST to verify if you have written a proper objective -> function -> jacobian set).  If we had it so you could register multiple tests (even in the update slot) we could provide a whole suite of potential useful output without much work.<span><font color="#888888"><br>


<br>- Peter<br><br></font></span></div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><font color="#888888">
  Barry<br>
</font></span><div><div><br>
><br>
> Dangit Jed!  -snes_compare_* is a seeerious mess and shouldn't be in SNESComputeJacobian().  Barry's recent holy war against string comparisons will find this some day and there will be a lot of explaining to do.<br>



><br>
> - Peter<br>
><br>
><br>
> On Thu, Dec 13, 2012 at 4:59 PM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>> wrote:<br>
> Surely you were aware of the -snes_compare_* options that can be activated in SNESComputeJacobian().<br>
><br>
> Can we settle on one common way to do this testing and perhaps remove -snes_type test.<br>
><br>
><br>
> On Thu, Dec 13, 2012 at 2:55 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
>    I got sick of -snes_type test only checking the Jacobian at the initial solution and not being able to test later Jacobians so I added -snes_check_jacobian that allows the regular running of SNESSolve() (also inside TS) and compares every Jacobian computed with a finite difference version.<br>



><br>
>   For example, (already found one bug in one example :-(). This may be the best thing I've added to PETSc in a decade.<br>
><br>
>    Barry<br>
><br>
><br>
> Barrys-MacBook-Pro:advection-diffusion-reaction barrysmith$ ./ex1 -snes_check_jacobian -snes_monitor  -ts_type arkimex | more<br>
>     0 SNES Function norm 2.182384017537e+00<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       1.68322e-09 = ||J - Jfd||//J|| 6.69028e-06  = ||J - Jfd||<br>
>     1 SNES Function norm 4.695397453383e-07<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       2.45109e-09 = ||J - Jfd||//J|| 9.74235e-06  = ||J - Jfd||<br>
>     2 SNES Function norm 4.020379099215e-13<br>
>     0 SNES Function norm 6.799718390407e-01<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       1.65487e-09 = ||J - Jfd||//J|| 6.5776e-06  = ||J - Jfd||<br>
>     1 SNES Function norm 4.558192078678e-08<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       2.93714e-09 = ||J - Jfd||//J|| 1.16742e-05  = ||J - Jfd||<br>
>     2 SNES Function norm 9.907308296870e-14<br>
>     0 SNES Function norm 1.000842117652e+00<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       1.24476e-09 = ||J - Jfd||//J|| 4.94755e-06  = ||J - Jfd||<br>
>     1 SNES Function norm 9.875108391772e-08<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       1.10818e-10 = ||J - Jfd||//J|| 4.40468e-07  = ||J - Jfd||<br>
>     2 SNES Function norm 7.677760150017e-14<br>
>     0 SNES Function norm 2.179048757949e+00<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       1.32338e-09 = ||J - Jfd||//J|| 5.27058e-07  = ||J - Jfd||<br>
>     1 SNES Function norm 4.625448863612e-05<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
>         Run with -snes_check_jacobian_display to show difference of hand-coded and finite difference Jacobian.<br>
>       1.57582e-09 = ||J - Jfd||//J|| 6.27588e-07  = ||J - Jfd||<br>
>     2 SNES Function norm 4.391784647745e-14<br>
>     0 SNES Function norm 6.761591873515e-01<br>
>         Testing hand-coded Jacobian, if the ratio is O(1.e-8), the hand-coded Jacobian is probably correct.<br>
><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>