[petsc-dev] TAO method selection (was "coding style")
Oxberry, Geoffrey Malcolm
oxberry1 at llnl.gov
Fri Aug 19 13:52:11 CDT 2016
On Aug 19, 2016, at 4:13 AM, Munson, Todd <tmunson at mcs.anl.gov<mailto:tmunson at mcs.anl.gov>> wrote:
Hi!
The only provable way to test for linearity of a function is using
code analysis.
A quick hack that should work okay is to evaluate the gradient at
two (or more) random points and calculate the distance between
the gradients. Note: this is not a good test for piecewise
linear functions, as you would need the random points to
lie in different regions to detect that the gradient is
not constant.
Something similar can be used for quadratics. Here you evaluate
the Hessian at two random points. You really want to calculate
the distance between the matrices. I did not find that method
in the PETSc documentation. Therefore, I would compare the
values of Hessian vector products, H1*y - H2*y where y is
a random vector.
You could call MatNorm (http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNorm.html), and use it to determine if, say, the infinity-norm of the difference between the matrices is small.
Hessian vector products could also potentially work. I think there might be some papers on estimating matrix norms from matrix-vector products, but if I remember correctly the last time I looked this up, some of these algorithms require transposes and may not be scalable.
These hacks really prove that the function is not linear or
not quadratic, but cannot truly establish that the function
is linear or quadratic.
Todd.
On Aug 19, 2016, at 2:40 AM, Marco Zocca <zocca.marco at gmail.com<mailto:zocca.marco at gmail.com>> wrote:
How does a numerical method test for linearity (or in general order of
nonlinearity) of an operator? By comparing function value with the
first two Taylor terms, within machine precision?
I suspect only code analysis ("reification", as in analysis of the
expression syntax tree) would be feasible and reliable for general
problems.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20160819/9412857e/attachment.html>
More information about the petsc-dev
mailing list