From 640104645eebb80274cc12fc6e43401caa8eedd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BRIOL?= Date: Wed, 3 Jul 2024 19:04:36 +0200 Subject: [PATCH] refactor: Improve harmonic analysis performance with Eigen LDLT solver --- src/library/wave/table.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/wave/table.cpp b/src/library/wave/table.cpp index 9a3de78..78fb3da 100644 --- a/src/library/wave/table.cpp +++ b/src/library/wave/table.cpp @@ -359,7 +359,8 @@ auto Table::harmonic_analysis(const Eigen::Ref& h, H.topRows(w_size) = f.array() * vu.array().cos(); H.bottomRows(w_size) = f.array() * vu.array().sin(); - auto solution = ((H * H.transpose()).inverse() * H) * h; + Eigen::LDLT ldlt(H * H.transpose()); + Eigen::VectorXd solution = ldlt.solve(H * h); result.real() = solution.topRows(w_size); result.imag() = solution.bottomRows(w_size);