From 7aa921531a465b3d821af8e71fea6a9369b8ba3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BRIOL?= Date: Wed, 9 Oct 2024 23:57:24 +0200 Subject: [PATCH] Refactor beta coefficient calculation in tidal model to use more portable Eigen syntax. --- include/fes/tidal_model/lgp.hpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/include/fes/tidal_model/lgp.hpp b/include/fes/tidal_model/lgp.hpp index 7311c9a..f94361c 100644 --- a/include/fes/tidal_model/lgp.hpp +++ b/include/fes/tidal_model/lgp.hpp @@ -225,7 +225,7 @@ class LGP1 : public LGP { /// @return The beta coefficients. inline auto calculate_beta(const double x, const double y) const -> Eigen::Matrix override { - return Eigen::Matrix({1 - x - y, x, y}); + return (Eigen::Matrix() << 1 - x - y, x, y).finished(); } /// @brief Set the state of the tidal model. @@ -272,15 +272,20 @@ class LGP2 : public LGP { /// @return The beta coefficients. inline auto calculate_beta(const double x, const double y) const -> Eigen::Matrix override { - return Eigen::Matrix({ - // - 2 * (x + y - 0.5) * (x + y - 1), // 2x² + 2y² + 4xy - 3x - 3y + 1 - -4 * x * (x + y - 1), // -4x² - 4xy + 4x - 2 * x * (x - 0.5), // 2x² - x - 4 * x * y, // 4xy - 2 * y * (y - 0.5), // 2y² - y - -4 * y * (x + y - 1) // -4y² - 4xy + 4y - }); + return (Eigen::Matrix() + // 2x² + 2y² + 4xy - 3x - 3y + 1 + << 2 * (x + y - 0.5) * (x + y - 1), + // -4x² - 4xy + 4x + -4 * x * (x + y - 1), + // 2x² - x + 2 * x * (x - 0.5), + // 4xy + 4 * x * y, + // 2y² - y + 2 * y * (y - 0.5), + // -4y² - 4xy + 4y + -4 * y * (x + y - 1)) + .finished(); } /// @brief Set the state of the tidal model.