Loading...
Searching...
No Matches
MinimumImage.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2#include "eon/PbcSimd.h"
3#include <minimage.hpp>
4#include <stdexcept>
5
6namespace eonc::pbc {
7void closestDisplacements(double *data, size_t coordinates,
8 const double *rowMajorCell) {
9 if (coordinates % 3 != 0)
10 throw std::invalid_argument(
11 "periodic differences require Cartesian triples");
12 if (coordinates == 0)
13 return;
14 const auto cell = minimage::Cell::from_con(rowMajorCell);
15 for (size_t j = 0; j < coordinates; j += 3) {
16 const auto image = cell.displacement_euclidean(
17 {0.0, 0.0, 0.0}, {data[j], data[j + 1], data[j + 2]});
18 for (size_t k = 0; k < 3; ++k)
19 data[j + k] = image[k];
20 }
21}
22} // namespace eonc::pbc
void closestDisplacements(double *data, size_t coordinates, const double *rowMajorCell)