From 4547f7f376f2b602f2073b1d02473a0621aed333 Mon Sep 17 00:00:00 2001
From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de>
Date: Thu, 22 Apr 2021 17:43:24 +0200
Subject: [PATCH] added cubic root

---
 corsika/framework/units/quantity.hpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/corsika/framework/units/quantity.hpp b/corsika/framework/units/quantity.hpp
index 5430fa398..7b5bd3587 100644
--- a/corsika/framework/units/quantity.hpp
+++ b/corsika/framework/units/quantity.hpp
@@ -468,6 +468,9 @@ namespace phys {
       template <typename D, typename X>
       friend detail::Root<D, 2, X> sqrt(quantity<D, X> const& x);
 
+      template <typename D, typename X>
+      friend detail::Root<D, 3, X> cbrt(quantity<D, X> const& x);
+
       // comparison
 
       template <typename D, typename X, typename Y>
@@ -679,6 +682,16 @@ namespace phys {
       return detail::Root<D, 2, X>(std::sqrt(x.m_value));
     }
 
+    /// cubic root.
+
+    template <typename D, typename X>
+    detail::Root<D, 3, X> cbrt(quantity<D, X> const& x) {
+      static_assert(detail::root<D, 3, X>::all_even_multiples,
+                    "root result dimensions must be integral");
+
+      return detail::Root<D, 3, X>(std::cbrt(x.m_value));
+    }
+
     // Comparison operators
 
     /// equality.
-- 
GitLab