Template Function otyca::close_enough

Function Documentation

template<typename T>
bool otyca::close_enough(const arma::Mat<T> &A, const arma::Mat<T> &B, double tolerance)

Compares two matrices to see if they are close enough within a given tolerance.

This function compares two matrices element-wise and computes the maximum absolute and relative differences. It then prints the matrices and the differences, and returns whether the matrices are close enough based on the provided tolerance.

Template Parameters:

T – The type of the elements in the matrices (e.g., float, double).

Parameters:
  • A – The first matrix to compare.

  • B – The second matrix to compare.

  • tolerance – The tolerance value for comparison.

Returns:

true if the matrices are close enough, false otherwise.