xo-unit: refactor: make natural_unit.reciprocal() a method

This commit is contained in:
Roland Conybeare 2024-04-24 11:30:41 -04:00
commit ac232a397a

View file

@ -13,6 +13,9 @@ namespace xo {
namespace qty {
using nu_abbrev_type = flatstring<32>;
template <typename Int>
class natural_unit;
/** @class natural_unit
* @brief an array representing the cartesian product of distinct basis-power-units
*
@ -37,6 +40,15 @@ namespace xo {
constexpr bpu<Int> * bpu_v() const { return bpu_v_; }
constexpr natural_unit reciprocal() const {
natural_unit retval;
for (std::size_t i = 0; i < this->n_bpu(); ++i)
retval.push_back((*this)[i].reciprocal());
return retval;
}
constexpr nu_abbrev_type abbrev() const {
nu_abbrev_type retval;
@ -303,18 +315,6 @@ namespace xo {
1.0 /*outer_scale_sq*/);
}
template <typename Int>
constexpr natural_unit<Int>
nu_reciprocal(const natural_unit<Int> & nu)
{
natural_unit<Int> retval;
for (std::size_t i = 0; i < nu.n_bpu(); ++i)
retval.push_back(nu[i].reciprocal());
return retval;
} /*nunit_reciprocal*/
} /*namespace detail*/
namespace nu2 {