Skip to content

Commit

Permalink
Refactor beta coefficient calculation in tidal model to use more port…
Browse files Browse the repository at this point in the history
…able Eigen syntax.
  • Loading branch information
fbriol committed Oct 9, 2024
1 parent 2fb36d1 commit 7aa9215
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions include/fes/tidal_model/lgp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class LGP1 : public LGP<T, 1> {
/// @return The beta coefficients.
inline auto calculate_beta(const double x, const double y) const
-> Eigen::Matrix<double, 3, 1> override {
return Eigen::Matrix<double, 3, 1>({1 - x - y, x, y});
return (Eigen::Matrix<double, 3, 1>() << 1 - x - y, x, y).finished();
}

/// @brief Set the state of the tidal model.
Expand Down Expand Up @@ -272,15 +272,20 @@ class LGP2 : public LGP<T, 2> {
/// @return The beta coefficients.
inline auto calculate_beta(const double x, const double y) const
-> Eigen::Matrix<double, 6, 1> override {
return Eigen::Matrix<double, 6, 1>({
//
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<double, 6, 1>()
// 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.
Expand Down

0 comments on commit 7aa9215

Please sign in to comment.