25 template <
class Scalar,
int M,
int N>
28 Eigen::Matrix<Scalar, M, N>
const& lhs,
29 Eigen::Matrix<Scalar, M, N>
const& rhs,
34 std::string
const& file,
36 std::string
const&
func,
37 std::string
const&
str) {
41 Scalar max_error = 0.0;
42 int max_error_dim = -1;
44 for (
int i = 0; i < lhs.reshaped().rows(); ++i) {
45 auto lhs_abs = abs(lhs.reshaped()[i]);
46 auto rhs_abs = abs(rhs.reshaped()[i]);
48 if (
min(lhs_abs, rhs_abs) < thr) {
50 Scalar err = abs(lhs.reshaped()[i] - rhs.reshaped()[i]);
51 if (err > max_error) {
57 Scalar err = abs((lhs.reshaped()[i] / rhs.reshaped()[i]) - 1.0);
58 if (err > max_error) {
65 if (max_error < thr) {
70 farm_ng::LogLevel::critical,
73 "Not true: {} near {}; has error of {} in {} (thr: "
74 "{})\n{}\n{}\n{}\nvs.\n{}\n{}\n{}",
75 absolute ?
"absolute" :
"relative",
81 lhs.reshaped()[max_error_dim],
84 rhs.reshaped()[max_error_dim],