53 template <
int Len,
int Mass,
int Time,
int Current,
int Temp,
int Mol,
int Li,
int Angle,
int Byte >
55 :
quantity< physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte >, float >
62 template <
int Exp,
char... Unit >
65 static_assert( Exp > -10 && Exp < 10 );
66 constexpr std::size_t unit_n =
sizeof...( Unit );
68 if constexpr ( Exp == 0 ) {
69 return std::array< char, 0 >{};
70 }
else if constexpr ( Exp == 1 ) {
71 return std::array< char, unit_n >{ Unit... };
73 constexpr std::size_t char_n = unit_n + 1 + ( Exp > 0 ? 1 : 2 );
74 std::array< char, char_n > buffer{ Unit... };
75 std::size_t n =
sizeof...( Unit );
79 buffer[n++] = -Exp +
'0';
81 buffer[n++] = Exp +
'0';
87 template <
int Exp,
char... Unit >
91 single_unit< Len, 'm' >,
92 single_unit< Mass, 'k', 'g' >,
93 single_unit< Time, 's' >,
94 single_unit< Current, 'A' >,
95 single_unit< Temp, 'K' >,
96 single_unit< Mol, 'm', 'o', 'l' >,
97 single_unit< Li, 'c', 'd' >,
98 single_unit< Angle, 'r', 'a', 'd' >,
99 single_unit< Byte, 'B' > );
103 return {
unit.data(),
unit.size() };
171 Byte0 + Byte1 >{ ( *lh ) * ( *rh ) };
209 Byte0 - Byte1 >{ ( *lh ) / ( *rh ) };
214 template <
int Len,
int Mass,
int Time,
int Current,
int Temp,
int Mol,
int Li,
int Angle,
int Byte >
218 Len % 2 == 0 && Mass % 2 == 0 && Time % 2 == 0 && Current % 2 == 0 && Temp % 2 == 0 &&
219 Mol % 2 == 0 && Li % 2 == 0 && Angle % 2 == 0 && Byte % 2 == 0,
220 "sqrt() over physical_quantity can be used only if all of the units are power of 2" );
230 Byte / 2 >{
float{
std::sqrt( *val ) } };
258 Byte * Power >{
static_cast< float >(
std::pow( *val, Power ) ) };
261 #ifdef EMLABCPP_USE_OSTREAM
262 template <
int Len,
int Mass,
int Time,
int Current,
int Temp,
int Mol,
int Li,
int Angle,
int Byte >
265 physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte >
const& q )
Class representing generic quantity.
Definition: quantity.h:63
constexpr quantity() noexcept
Definition: quantity.h:79
MIT License.
Definition: impl.h:31
physical_quantity< 1, 0, 0, 0, 0, 0, 0, 0, 0 > length
Definition: physical_quantity.h:110
constexpr auto sqrt(physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte > val)
Square root of physical quantity is square root of it's value and the exponents are divided in half.
Definition: physical_quantity.h:215
constexpr point< N > operator*(point< N > a, point< N > const &b)
Multiplication of points multiplies each coordinate of A by coordinate of B on same dimension.
Definition: point.h:74
constexpr angle pi
Constants of units that are relevant for us.
Definition: physical_quantity.h:134
constexpr auto pow(physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte > val)
Power of physical quantity is power of root of it's value and the exponents are multiplied by the val...
Definition: physical_quantity.h:247
constexpr Derived operator/(vec_point_base< Derived, N > const &a, T s)
Divides each coordinate of A by item 's' of type T, if T satifies std::is_arithmetic.
Definition: vec_point_base.h:170
constexpr auto merge_arrays(Arr &&first, Arrs &&... arrs)
Expects multiple std::arrays on input, and merges all together into one std::array instance.
Definition: algorithm.h:531
std::ostream & operator<<(std::ostream &os, string_buffer< N > const &sb)
Definition: string_buffer.h:112
physical_quantity represents all physical units defined using the International System of Units and m...
Definition: physical_quantity.h:56
static std::string_view get_unit()
Definition: physical_quantity.h:101
static constexpr std::array single_unit
Definition: physical_quantity.h:88
static consteval auto get_single_unit()
Definition: physical_quantity.h:63
static constexpr std::array unit
Definition: physical_quantity.h:90