MCPcopy Create free account
hub / github.com/bgrimstad/splinter / getError

Function getError

test/testingutilities.cpp:23–36  ·  view source on GitHub ↗

See https://en.wikipedia.org/wiki/Relative_change_and_difference#Formulae

Source from the content-addressed store, hash-verified

21
22// See https://en.wikipedia.org/wiki/Relative_change_and_difference#Formulae
23double getError(double exactVal, double approxVal)
24{
25 double maxAbsVal = std::max(std::abs(exactVal), std::abs(approxVal));
26
27 // Both are ~0
28 if(maxAbsVal < 1e-14)
29 {
30 return 0.0;
31 }
32
33 double absError = std::abs(exactVal - approxVal);
34
35 return std::min(absError, absError / maxAbsVal);
36}
37
38// Checks if a is within margin of b
39bool equalsWithinRange(double a, double b, double margin)

Callers 3

compareFunctionValueFunction · 0.85
compareJacobianValueFunction · 0.85
isSymmetricHessianFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected