Skip to content
Snippets Groups Projects
Commit 2be33e47 authored by Oliver Sander's avatar Oliver Sander Committed by sander@FU-BERLIN.DE
Browse files

use the relative error when looking for differences between analytical and fd expressions

[[Imported from SVN: r8404]]
parent 775ba6e3
No related branches found
No related tags found
No related merge requests found
...@@ -316,7 +316,11 @@ void testEnergyGradient() ...@@ -316,7 +316,11 @@ void testEnergyGradient()
for (size_t k=0; k<gradient[j].size(); k++) for (size_t k=0; k<gradient[j].size(); k++)
diff = std::max(diff, std::fabs(gradient[j][k] - fdGradient[j][k])); diff = std::max(diff, std::fabs(gradient[j][k] - fdGradient[j][k]));
if (diff > 1e-4) { double maxRelError = 0;
for (size_t j=0; j<gradient.size(); j++)
maxRelError = std::max(maxRelError, diff/gradient[j].infinity_norm());
if (maxRelError > 1e-3) {
std::cout << "Analytical and FD gradients differ!" << std::endl; std::cout << "Analytical and FD gradients differ!" << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment