LArSoft  v10_04_05
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 448 of file geo_vectors_utils.h.

References util::abs(), and value.

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

449  {
450  return (std::abs(value) < tol) ? T{} : value;
451  } // 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 455 of file geo_vectors_utils.h.

References util::abs(), and value.

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

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