LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::vect::extra Namespace Reference

Convenience utilities not directly related to vectors. More...

Functions

template<typename T >
constexpr T roundValue0 (T value, T tol)
 Returns value, rounded to 0 if closer than tol. More...
 
template<typename T >
constexpr T roundValue01 (T value, T tol)
 Returns value, rounded to 0, -1 or +1 if closer than tol. More...
 

Detailed Description

Convenience utilities not directly related to vectors.

Function Documentation

template<typename T >
constexpr T geo::vect::extra::roundValue0 ( value,
tol 
)

Returns value, rounded to 0 if closer than tol.

Definition at line 450 of file geo_vectors_utils.h.

References util::abs(), and value.

Referenced by geo::vect::rounded0().

451  {
452  return (std::abs(value) < tol) ? T{} : value;
453  } // roundValue0()
constexpr auto abs(T v)
Returns the absolute value of the argument.
double value
Definition: spectrum.C:18
template<typename T >
constexpr T geo::vect::extra::roundValue01 ( value,
tol 
)

Returns value, rounded to 0, -1 or +1 if closer than tol.

Definition at line 457 of file geo_vectors_utils.h.

References util::abs(), and value.

Referenced by geo::vect::rounded01().

458  {
459  if (std::abs(value) < tol) return 0.;
460  if (std::abs(std::abs(value) - 1.) < tol) return (value > 0.) ? 1. : -1.;
461  return value;
462  } // roundValue01()
constexpr auto abs(T v)
Returns the absolute value of the argument.
double value
Definition: spectrum.C:18