Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 83f692e2 authored by vinciguerra_a's avatar vinciguerra_a
Browse files

Use switch/case over if for Lp norm

parent 8af9af95
No related branches found
No related tags found
1 merge request!74Implement inner product
......@@ -80,7 +80,9 @@ namespace ippl {
T local = 0;
const int shift = field.getNghost();
auto view = field.getView();
if (p == 0) {
switch (p) {
case 0:
{
Kokkos::parallel_reduce("Field::norm(0)",
Kokkos::MDRangePolicy<Kokkos::Rank<3>>({shift, shift, shift}, {
view.extent(0) - shift,
......@@ -96,9 +98,11 @@ namespace ippl {
MPI_Datatype type = get_mpi_datatype<T>(local);
MPI_Allreduce(&local, &globalMax, 1, type, MPI_MAX, Ippl::getComm());
return globalMax;
} else if (p == 2) {
}
case 2:
return std::sqrt(innerProduct(field, field));
} else {
default:
{
Kokkos::parallel_reduce("Field::norm(int) general",
Kokkos::MDRangePolicy<Kokkos::Rank<3>>({shift, shift, shift}, {
view.extent(0) - shift,
......@@ -114,6 +118,7 @@ namespace ippl {
MPI_Allreduce(&local, &globalSum, 1, type, MPI_SUM, Ippl::getComm());
return std::pow(globalSum, 1.0 / p);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment