Function navtk::utils::diff(const std::string&, const std::string&, const Matrix&, const Matrix&, double, double)

Function Documentation

std::string navtk::utils::diff(const std::string &before_name, const std::string &after_name, const Matrix &before, const Matrix &after, double rtol = 1e-05, double atol = 1e-08)

Returns a human-readable description of the difference between two matrices.

Returns an empty string if xt::allclose(before, after, rtol, atol).

In general, most code should use xt::allclose or xt::isclose instead. This function exists primarily for use from within gdb and unit tests.

When possible, the output will also be valid c++ code, assigning the value of before to after , and then making changes to match the value of after . For example, diff("in", "out", xt::eye(3), xt::eye(3) * 2) will yield:

out = in;
out(0, 0) = 2;  // in(0, 0) == 1
out(1, 1) = 2;  // in(1, 1) == 1
out(2, 2) = 2;  // in(2, 2) == 1

Special cases exist for transposes and mismatched dimensionality.

Parameters
  • before_name – A name to use in describing the before matrix.

  • after_name – A name to use in describing the after matrix.

  • before – Matrix supplying ‘expected’ data.

  • after – Matrix supplying ‘actual’ data.

  • rtolxt::isclose’s relative tolerance parameter (default 1e-05).

  • atolxt::isclose’s absolute tolerance parameter (default 1e-08).

Returns

Human-readable description of the difference between two matrices.