IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 0da1e57a authored by ralfulrich's avatar ralfulrich Committed by Nikos Karastathis
Browse files

finally made this running for quantities and doubles

parent 7ae5cde5
No related branches found
No related tags found
1 merge request!372Resolve "Commutative property with scalar multiplication is not supported in C8"
Pipeline #5577 passed
......@@ -241,9 +241,14 @@ namespace corsika {
/*
* scalar * vector multiplication
*/
template <typename TDimension, typename UDimension>
inline Vector<phys::units::detail::product_d<TDimension, UDimension>> operator*(
quantity<UDimension> const n, Vector<TDimension> const& vec) {
return vec * n;
}
template <typename TDimension>
inline Vector<TDimension> operator*(double const n, Vector<TDimension> const& vec) {
return vec * n;
}
} // namespace corsika
......@@ -142,6 +142,28 @@ namespace corsika {
auto dot(Vector<TDimension2> const& pV) const;
};
/**
* Free operator to allow commutative multiplications of quantities and Vector.
*
* @tparam TDimension
* @tparam UDimension
* @param n
* @param vec
* @return auto
*/
template <typename TDimension, typename UDimension>
Vector<phys::units::detail::product_d<TDimension, UDimension>> operator*(
quantity<UDimension> const n, Vector<TDimension> const& vec);
/**
* Free operator to allow commutative multiplications of normal double with Vector.
*
* @tparam TDimension
* @tparam UDimension
* @param n
* @param vec
* @return auto
*/
template <typename TDimension>
Vector<TDimension> operator*(double const n, Vector<TDimension> const& vec);
......
......@@ -46,6 +46,17 @@ TEST_CASE("Geometry CoordinateSystems") {
CHECK((p1.getCoordinates(rootCS) - coordinates).getNorm().magnitude() ==
Approx(0).margin(absMargin));
SECTION("basic operations") {
auto testV0 = v1 * 6;
CHECK(testV0.getNorm() / tesla == Approx(6));
auto testV1 = 6 * v1;
CHECK(testV1.getNorm() / tesla == Approx(6));
auto testV2 = 6_m * v1;
CHECK(testV2.getNorm() / (tesla * meter) == Approx(6));
auto testV3 = v1 * 6_m;
CHECK(testV3.getNorm() / (tesla * meter) == Approx(6));
}
SECTION("translations") {
QuantityVector<length_d> const translationVector{0_m, 4_m, 0_m};
CORSIKA_LOG_INFO("QuantityVector<length_d> translationVector={}", translationVector);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment