Celeritas 0.7+28f01d9
Loading...
Searching...
No Matches
Functions
ArrayQuantity.hh File Reference

Create and convert arrays of quantities. More...

#include <cstddef>
#include <type_traits>
#include "corecel/Types.hh"
#include "corecel/cont/Array.hh"
#include "Quantity.hh"

Functions

template<class Q , class... Args>
constexpr Array< Q, sizeof...(Args)> celeritas::make_quantity_array (Args const &... args) noexcept
 Construct an array of quantities from raw values.
 
template<class Q , size_type N>
constexpr Array< Q, N > celeritas::make_quantity_array (Array< typename Q::value_type, N > const &arr) noexcept
 Construct an array of quantities from raw values.
 
template<class UnitT , class ValueT , size_type N>
constexpr auto celeritas::native_value_from (Array< Quantity< UnitT, ValueT >, N > const &quant) noexcept
 Convert an array of quantities to native values.
 
template<class Q , class T , size_type N>
constexpr auto celeritas::native_value_to (Array< T, N > const &value) noexcept
 Convert an array of native values to an array of quantities.
 
template<class Q , size_type N>
constexpr auto celeritas::value_as (Array< Q, N > const &quant) noexcept -> std::enable_if_t< is_quantity_v< Q >, Array< typename Q::value_type, N > >
 Get the values from an array of quantities.
 

Detailed Description

Create and convert arrays of quantities.

Function Documentation

◆ make_quantity_array() [1/2]

template<class Q , class... Args>
constexpr Array< Q, sizeof...(Args)> celeritas::make_quantity_array ( Args const &...  args)
inlineconstexprnoexcept

Construct an array of quantities from raw values.

This helper function allows concise construction of arrays of quantities:

auto distances = make_quantity_array<CmLength>(1.0, 2.5, 3.7);

◆ make_quantity_array() [2/2]

template<class Q , size_type N>
constexpr Array< Q, N > celeritas::make_quantity_array ( Array< typename Q::value_type, N > const arr)
inlineconstexprnoexcept

Construct an array of quantities from raw values.

This helper function allows concise construction of arrays of quantities:

auto pos = make_quantity_array<CmLength>(hardcoded_pos_cm);

◆ native_value_from()

template<class UnitT , class ValueT , size_type N>
constexpr auto celeritas::native_value_from ( Array< Quantity< UnitT, ValueT >, N > const quant)
inlineconstexprnoexcept

Convert an array of quantities to native values.

This applies native_value_from element-wise to each component.

◆ native_value_to()

template<class Q , class T , size_type N>
constexpr auto celeritas::native_value_to ( Array< T, N > const value)
inlineconstexprnoexcept

Convert an array of native values to an array of quantities.

This applies native_value_to element-wise to each component.

◆ value_as()

template<class Q , size_type N>
constexpr auto celeritas::value_as ( Array< Q, N > const quant) -> std::enable_if_t<is_quantity_v<Q>, Array<typename Q::value_type, N>>
inlineconstexprnoexcept

Get the values from an array of quantities.

This applies value_as element-wise to each component.