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
No related merge requests found
...@@ -241,9 +241,14 @@ namespace corsika { ...@@ -241,9 +241,14 @@ namespace corsika {
/* /*
* scalar * vector multiplication * 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> template <typename TDimension>
inline Vector<TDimension> operator*(double const n, Vector<TDimension> const& vec) { inline Vector<TDimension> operator*(double const n, Vector<TDimension> const& vec) {
return vec * n; return vec * n;
} }
} // namespace corsika } // namespace corsika
...@@ -142,6 +142,28 @@ namespace corsika { ...@@ -142,6 +142,28 @@ namespace corsika {
auto dot(Vector<TDimension2> const& pV) const; 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> template <typename TDimension>
Vector<TDimension> operator*(double const n, Vector<TDimension> const& vec); Vector<TDimension> operator*(double const n, Vector<TDimension> const& vec);
......
...@@ -46,6 +46,17 @@ TEST_CASE("Geometry CoordinateSystems") { ...@@ -46,6 +46,17 @@ TEST_CASE("Geometry CoordinateSystems") {
CHECK((p1.getCoordinates(rootCS) - coordinates).getNorm().magnitude() == CHECK((p1.getCoordinates(rootCS) - coordinates).getNorm().magnitude() ==
Approx(0).margin(absMargin)); 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") { SECTION("translations") {
QuantityVector<length_d> const translationVector{0_m, 4_m, 0_m}; QuantityVector<length_d> const translationVector{0_m, 4_m, 0_m};
CORSIKA_LOG_INFO("QuantityVector<length_d> translationVector={}", translationVector); 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