Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Scalar concept to Value. #121

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/linear_algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ void matrix_of_quantity_tests()
matrix_of_quantity_divide_by_scalar();
}

template<units::Unit U = si::metre, units::Scalar Rep = double>
template<units::Unit U = si::metre, units::NumericValue Rep = double>
using length_v = si::length<U, vector<Rep>>;

template<units::Unit U = si::newton, units::Scalar Rep = double>
template<units::Unit U = si::newton, units::NumericValue Rep = double>
using force_v = si::force<U, vector<Rep>>;

void quantity_of_vector_add()
Expand Down Expand Up @@ -274,7 +274,7 @@ void quantity_of_vector_tests()
quantity_of_vector_divide_by_scalar();
}

template<units::Unit U = si::metre, units::Scalar Rep = double>
template<units::Unit U = si::metre, units::NumericValue Rep = double>
using length_m = si::length<U, matrix<Rep>>;

void quantity_of_matrix_add()
Expand Down
2 changes: 1 addition & 1 deletion example/measurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class measurement {
value_type uncertainty_{};
};

static_assert(units::Scalar<measurement<double>>);
static_assert(units::NumericValue<measurement<double>>);

} // namespace

Expand Down
4 changes: 2 additions & 2 deletions src/include/units/bits/common_quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace units {

template<Dimension D, UnitOf<D> U, Scalar Rep>
template<Dimension D, UnitOf<D> U, NumericValue Rep>
class quantity;

namespace detail {
Expand Down Expand Up @@ -59,7 +59,7 @@ struct common_quantity_impl<quantity<D1, U1, Rep1>, quantity<D2, U2, Rep2>, Rep>

} // namespace detail

template<Quantity Q1, Quantity Q2, Scalar Rep = std::common_type_t<typename Q1::rep, typename Q2::rep>>
template<Quantity Q1, Quantity Q2, NumericValue Rep = std::common_type_t<typename Q1::rep, typename Q2::rep>>
requires equivalent_dim<typename Q1::dimension, typename Q2::dimension>
using common_quantity = detail::common_quantity_impl<Q1, Q2, Rep>::type;

Expand Down
4 changes: 2 additions & 2 deletions src/include/units/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ inline constexpr bool is_wrapped_quantity<T> = Quantity<typename T::value_type>
template<typename T>
concept WrappedQuantity = detail::is_wrapped_quantity<T>;

// Scalar
// NumericValue

namespace detail {

Expand Down Expand Up @@ -283,7 +283,7 @@ concept not_constructible_from_integral =
* Satisfied by types that satisfy `(!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>`.
*/
template<typename T>
concept Scalar =
concept NumericValue =
(!Quantity<T>) &&
(!WrappedQuantity<T>) &&
std::regular<T> &&
Expand Down
4 changes: 2 additions & 2 deletions src/include/units/customization_points.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace units {
*
* @tparam Rep a representation type for which a type trait is defined
*/
template<Scalar Rep>
template<NumericValue Rep>
inline constexpr bool treat_as_floating_point = std::is_floating_point_v<Rep>;

/**
Expand All @@ -49,7 +49,7 @@ inline constexpr bool treat_as_floating_point = std::is_floating_point_v<Rep>;
*
* @tparam Rep a representation type for which a type trait is defined
*/
template<Scalar Rep>
template<NumericValue Rep>
struct quantity_values {
static constexpr Rep zero() noexcept { return Rep(0); }
static constexpr Rep one() noexcept { return Rep(1); }
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/data/bitrate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct pebibit_per_second : deduced_unit<pebibit_per_second, dim_bitrate, pebibi
template<typename T>
concept Bitrate = QuantityOf<T, dim_bitrate>;

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using bitrate = quantity<dim_bitrate, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/data/information.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct dim_information : base_dimension<"information", bit> {};
template<typename T>
concept Information = QuantityOf<T, dim_information>;

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using information = quantity<dim_information, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/acceleration.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace units::physical::cgs {
struct gal : named_unit<gal, "Gal", si::prefix> {};
struct dim_acceleration : physical::dim_acceleration<dim_acceleration, gal, dim_length, dim_time> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using acceleration = quantity<dim_acceleration, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using si::square_centimetre;

struct dim_area : physical::dim_area<dim_area, square_centimetre, dim_length> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using area = quantity<dim_area, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/energy.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct erg : named_unit<erg, "erg", si::prefix> {};

struct dim_energy : physical::dim_energy<dim_energy, erg, dim_force, dim_length> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using energy = quantity<dim_energy, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/force.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct dyne : named_unit<dyne, "dyn", si::prefix> {};

struct dim_force : physical::dim_force<dim_force, dyne, dim_mass, dim_acceleration> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using force = quantity<dim_force, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/length.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using si::centimetre;

struct dim_length : physical::dim_length<centimetre> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using length = quantity<dim_length, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/mass.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using si::gram;

struct dim_mass : physical::dim_mass<gram> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using mass = quantity<dim_mass, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct erg_per_second : unit<erg_per_second> {};

struct dim_power : physical::dim_power<dim_power, erg_per_second, dim_energy, dim_time> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using power = quantity<dim_power, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/pressure.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct barye : named_unit<barye, "Ba", si::prefix> {};

struct dim_pressure : physical::dim_pressure<dim_pressure, barye, dim_force, dim_area> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using pressure = quantity<dim_pressure, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/cgs/speed.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace units::physical::cgs {
struct centimetre_per_second : unit<centimetre_per_second> {};
struct dim_speed : physical::dim_speed<dim_speed, centimetre_per_second, dim_length, dim_time> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using speed = quantity<dim_speed, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/natural/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace units::physical::natural {

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto speed_of_light = speed<unitless, Rep>(1);

} // namespace units::physical::natural
16 changes: 8 additions & 8 deletions src/include/units/physical/natural/dimensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@
namespace units::physical::natural {

struct dim_length : physical::dim_length<inverted_gigaelectronvolt> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using length = quantity<dim_length, U, Rep>;

struct dim_time : physical::dim_time<inverted_gigaelectronvolt> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using time = quantity<dim_time, U, Rep>;

struct dim_mass : physical::dim_mass<gigaelectronvolt> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using mass = quantity<dim_mass, U, Rep>;

struct dim_speed : physical::dim_speed<dim_speed, unitless, dim_length, dim_time> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using speed = quantity<dim_speed, U, Rep>;

struct dim_acceleration : physical::dim_acceleration<dim_acceleration, gigaelectronvolt, dim_length, dim_time> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using acceleration = quantity<dim_acceleration, U, Rep>;

struct dim_force : physical::dim_force<dim_force, square_gigaelectronvolt, dim_mass, dim_acceleration> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using force = quantity<dim_force, U, Rep>;

struct dim_momentum : physical::dim_momentum<dim_momentum, gigaelectronvolt, dim_mass, dim_speed> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using momentum = quantity<dim_momentum, U, Rep>;

struct dim_energy : physical::dim_energy<dim_energy, gigaelectronvolt, dim_force, dim_length> {};
template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using energy = quantity<dim_force, U, Rep>;

// Typical UDLs will not work here as the same units are reused by many quantities.
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/absorbed_dose.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct yottagray : prefixed_unit<yottagray, yotta, gray> {};

struct dim_absorbed_dose : physical::dim_absorbed_dose<dim_absorbed_dose, gray, dim_energy, dim_mass> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using absorbed_dose = quantity<dim_absorbed_dose, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/acceleration.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace units::physical::si {
struct metre_per_second_sq : unit<metre_per_second_sq> {};
struct dim_acceleration : physical::dim_acceleration<dim_acceleration, metre_per_second_sq, dim_length, dim_time> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using acceleration = quantity<dim_acceleration, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/angle.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct radian : named_unit<radian, "rad", prefix> {};

struct dim_angle : physical::dim_angle<radian> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using angle = quantity<dim_angle, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct square_yottametre : deduced_unit<square_yottametre, dim_area, yottametre>

struct hectare : alias_unit<square_hectometre, "ha", no_prefix> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using area = quantity<dim_area, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/capacitance.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct yottafarad : prefixed_unit<yottafarad, yotta, farad> {};

struct dim_capacitance : physical::dim_capacitance<dim_capacitance, farad, dim_electric_charge, dim_voltage> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using capacitance = quantity<dim_capacitance, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/catalytic_activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct enzyme_unit : named_scaled_unit<enzyme_unit, "U", prefix, ratio<1, 60, -6

struct dim_catalytic_activity : physical::dim_catalytic_activity<dim_catalytic_activity, katal, dim_time, dim_substance> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using catalytic_activity = quantity<dim_catalytic_activity, U, Rep>;

inline namespace literals {
Expand Down
4 changes: 2 additions & 2 deletions src/include/units/physical/si/charge_density.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ struct coulomb_per_metre_sq : unit<coulomb_per_metre_sq> {};
struct dim_charge_density : physical::dim_charge_density<dim_charge_density, coulomb_per_metre_cub, dim_electric_charge, dim_length> {};
struct dim_surface_charge_density : physical::dim_surface_charge_density<dim_surface_charge_density, coulomb_per_metre_sq, dim_electric_charge, dim_length> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using charge_density = quantity<dim_charge_density, U, Rep>;

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using surface_charge_density = quantity<dim_surface_charge_density, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/concentration.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace units::physical::si {
struct mol_per_metre_cub : unit<mol_per_metre_cub> {};
struct dim_concentration : physical::dim_concentration<dim_concentration, mol_per_metre_cub, dim_substance, dim_length> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using concentration = quantity<dim_concentration, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/conductance.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct yottasiemens : prefixed_unit<yottasiemens, yotta, siemens> {};

struct dim_conductance : physical::dim_conductance<dim_conductance, siemens, dim_resistance> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using conductance = quantity<dim_conductance, U, Rep>;

inline namespace literals {
Expand Down
18 changes: 9 additions & 9 deletions src/include/units/physical/si/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@

namespace units::physical::si::si2019 {

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto planck_constant = energy<joule, Rep>(6.62607015e-34) * time<second, Rep>(1);

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto reduced_planck_constant = energy<gigaelectronvolt, Rep>(6.582119569e-10) * time<second, Rep>(1);

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto elementary_charge = electric_charge<coulomb, Rep>(1.602176634e-19);

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto boltzmann_constant = energy<joule, Rep>(1.380649e-23) / temperature<kelvin, Rep>(1);

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto avogadro_constant = Rep(6.02214076e23) / substance<mole, Rep>(1);

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto speed_of_light = speed<metre_per_second, Rep>(299'792'458);

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto hyperfine_structure_transition_frequency = frequency<hertz, Rep>(9'192'631'770);

// template<Scalar Rep = double>
// template<NumericValue Rep = double>
// inline constexpr auto luminous_efficacy = 683q_lm / 1q_W;

template<Scalar Rep = double>
template<NumericValue Rep = double>
inline constexpr auto standard_gravity = acceleration<metre_per_second_sq, Rep>(9.80665);

} // namespace units::physical::si::si2019
2 changes: 1 addition & 1 deletion src/include/units/physical/si/current.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct yottaampere : prefixed_unit<yottaampere, yotta, ampere> {};

struct dim_electric_current : physical::dim_electric_current<ampere> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using current = quantity<dim_electric_current, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/current_density.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ampere_per_metre_sq : unit<ampere_per_metre_sq> {};

struct dim_current_density : physical::dim_current_density<dim_current_density, ampere_per_metre_sq, dim_electric_current, dim_length> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using current_density = quantity<dim_current_density, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/density.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct kilogram_per_metre_cub : unit<kilogram_per_metre_cub> {};

struct dim_density : physical::dim_density<dim_density, kilogram_per_metre_cub, dim_mass, dim_length> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using density = quantity<dim_density, U, Rep>;

inline namespace literals {
Expand Down
2 changes: 1 addition & 1 deletion src/include/units/physical/si/dynamic_viscosity.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace units::physical::si {
struct pascal_second : unit<pascal_second> {};
struct dim_dynamic_viscosity : physical::dim_dynamic_viscosity<dim_dynamic_viscosity, pascal_second, dim_pressure, dim_time> {};

template<Unit U, Scalar Rep = double>
template<Unit U, NumericValue Rep = double>
using dynamic_viscosity = quantity<dim_dynamic_viscosity, U, Rep>;

inline namespace literals {
Expand Down
Loading