Commit ce55ce07 authored by Oliver Sander's avatar Oliver Sander
Browse files

Allow for functionals whose Hessians have off-diagonal entries

parent 78961ec7
......@@ -160,10 +160,15 @@ void testHessian(Functional& functional,
for (auto&& testPoint : testPoints)
// Get the Hessian at the current test point as computed by 'functional'
/** \todo This code is conservative, and adds the entire matrix to the pattern.
* A smarter code would ask the functional for all entries it intends to write,
* but I don't know if and how this is possible.
MatrixIndexSet diagonalPattern;
diagonalPattern.resize(testPoint.size(), testPoint.size());
for (size_t i=0; i<testPoint.size(); i++)
for (size_t j=0; j<testPoint.size(); j++)
typename Functional::MatrixType hessian;
......@@ -208,7 +213,7 @@ void testHessian(Functional& functional,
neighborValues[ii] = functional(neighborPoints[ii]);
// The current partial derivative
double derivative = (i==j) ? hessian[i][j][k][l] : 0.0;
double derivative = hessian.entry(i,j) ? hessian[i][j][k][l] : 0.0;
double finiteDiff = (neighborValues[0]
- neighborValues[1] - neighborValues[2]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment