Template Function librapid::isClose(const GenericVector<Scalar, Dims>&, const GenericVector<Scalar, Dims>&, double)#

Function Documentation#

template<typename Scalar, int64_t Dims>
bool librapid::isClose(const GenericVector<Scalar, Dims> &a, const GenericVector<Scalar, Dims> &b, double tolerance = -1)#

Returns true if the two vectors are within the given tolerance of each other.

This function is only defined for vectors of the same dimensionality and scalar type, and returns true if the magnitude of the difference between the two vectors is less than the given tolerance.

This function is useful for comparing floating point vectors for equality, since floating point rounding errors can cause seemingly identical vectors to be slightly different.

Template Parameters
  • Scalar – The scalar type of the vectors

  • Dims – Number of dimensions of the vectors

Parameters
  • a – The first vector

  • b – The second vector

  • tolerance – Tolerance

Returns

True if the vectors are within the given tolerance of each other