Skip to content

Commit

Permalink
fix some math
Browse files Browse the repository at this point in the history
  • Loading branch information
mkstoyanov committed Jul 11, 2024
1 parent a4dabb5 commit eba29cf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,14 @@ int main(int argc, char **argv)
transformer, degree, time + pde->get_dt());

// calculate root mean squared error
auto const diff = f_val - analytic_solution;
auto const RMSE = [&diff]() {
asgard::fk::vector<prec> squared(diff);
std::transform(squared.begin(), squared.end(), squared.begin(),
[](prec const &elem) { return elem * elem; });
auto const mean = std::accumulate(squared.begin(), squared.end(), 0.0) /
squared.size();
return std::sqrt(mean);
auto const RMSE = [&]() {
prec s{0}, d{0};
for (int i = 0; i < f_val.size(); i++)
{
d = f_val[i] - analytic_solution[i];
s += d * d;
}
return std::sqrt(s);
}();
auto const relative_error =
RMSE / asgard::inf_norm(analytic_solution) * 100;
Expand Down

0 comments on commit eba29cf

Please sign in to comment.