relativeError function
Returns relative error between calculated and correct.
The type of calculated and correct must match and can
be any vector, matrix, or quaternion.
Implementation
double relativeError(dynamic calculated, dynamic correct) {
if (calculated is num && correct is num) {
final diff = (calculated - correct).abs().toDouble();
return diff / correct;
}
// avoiding an `as double` cast here to maximize speed on dart2js
// ignore: avoid_dynamic_calls, return_of_invalid_type
return calculated.relativeError(correct);
}