Skip to content

Commit

Permalink
refactor: Improve harmonic analysis performance with Eigen LDLT solver
Browse files Browse the repository at this point in the history
  • Loading branch information
fbriol committed Jul 3, 2024
1 parent 05033a4 commit 6401046
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/library/wave/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ auto Table::harmonic_analysis(const Eigen::Ref<const Eigen::VectorXd>& 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<Eigen::MatrixXd> ldlt(H * H.transpose());
Eigen::VectorXd solution = ldlt.solve(H * h);
result.real() = solution.topRows(w_size);
result.imag() = solution.bottomRows(w_size);

Expand Down

0 comments on commit 6401046

Please sign in to comment.