Celeritas 0.7+cf8d83d
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"
#include <ostream>

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 , std::size_t 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 , std::size_t 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 , std::size_t 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 , std::size_t 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.
 
template<class UnitT , class ValueT , std::size_t N>
std::ostream & celeritas::operator<< (std::ostream &os, Array< Quantity< UnitT, ValueT >, N > const &q)
 Output a quantity array with its label.
 

Detailed Description

Create and convert arrays of quantities.

See also
corecel/math/Quantity.test.cc

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 , std::size_t 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 , std::size_t 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 , std::size_t 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.

◆ operator<<()

template<class UnitT , class ValueT , std::size_t N>
std::ostream & celeritas::operator<< ( std::ostream &  os,
Array< Quantity< UnitT, ValueT >, N > const q 
)

Output a quantity array with its label.

This overload is more specialized than the generic Array operator<< and is therefore preferred by partial ordering for Quantity element types.

◆ value_as()

template<class Q , std::size_t 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.