Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:52:43

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file corecel/math/UnitUtils.hh
0006 //! \brief Helpers for unit trait classes
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Macros.hh"
0011 
0012 namespace celeritas
0013 {
0014 //---------------------------------------------------------------------------//
0015 //! Value is 1 / C1::value()
0016 template<class C1>
0017 struct UnitInverse
0018 {
0019     //! Get the conversion factor of the resulting unit
0020     static CELER_CONSTEXPR_FUNCTION auto value() noexcept -> decltype(auto)
0021     {
0022         return 1 / C1::value();
0023     }
0024 };
0025 
0026 //---------------------------------------------------------------------------//
0027 //! Value is C1::value() / C2::value()
0028 template<class C1, class C2>
0029 struct UnitDivide
0030 {
0031     //! Get the conversion factor of the resulting unit
0032     static CELER_CONSTEXPR_FUNCTION auto value() noexcept -> decltype(auto)
0033     {
0034         return C1::value() / C2::value();
0035     }
0036 };
0037 
0038 //! Value is C1::value() * C2::value()
0039 template<class C1, class C2>
0040 struct UnitProduct
0041 {
0042     //! Get the conversion factor of the resulting unit
0043     static CELER_CONSTEXPR_FUNCTION auto value() noexcept -> decltype(auto)
0044     {
0045         return C1::value() * C2::value();
0046     }
0047 };
0048 
0049 //---------------------------------------------------------------------------//
0050 }  // namespace celeritas