Skip to content

Commit

Permalink
Merge branch 'python' into le_corner_case
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Jul 17, 2024
2 parents 71a2760 + 3c060c5 commit 08111ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/core/Particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,17 @@ struct ParticleForce {

friend ParticleForce operator+(ParticleForce const &lhs,
ParticleForce const &rhs) {
#ifdef ROTATION
return {lhs.f + rhs.f, lhs.torque + rhs.torque};
#else
return lhs.f + rhs.f;
#endif
ParticleForce result = lhs;
result += rhs;
return result;
}

ParticleForce &operator+=(ParticleForce const &rhs) {
return *this = *this + rhs;
f += rhs.f;
#ifdef ROTATION
torque += rhs.torque;
#endif
return *this;
}

/** force. */
Expand Down
13 changes: 11 additions & 2 deletions src/core/algorithm/periodic_fold.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@
#define CORE_ALGORITHM_PERIODIC_FOLD_HPP

#include <cmath>
#include <concepts>
#include <limits>
#include <type_traits>
#include <utility>

// Define a concept that checks if a type T is an integer or a reference to an
// integer
template <typename T>
concept IntegralOrRef = std::integral<std::remove_reference_t<T>>;
template <typename T>
concept FloatingPointOrRef = std::floating_point<std::remove_reference_t<T>>;

namespace Algorithm {
/**
* @brief Fold value into primary interval.
Expand All @@ -32,7 +41,7 @@ namespace Algorithm {
* @param l Length of primary interval
* @return x folded into [0, l) and number of folds.
*/
template <typename T, typename I>
template <FloatingPointOrRef T, IntegralOrRef I>
std::pair<T, I> periodic_fold(T x, I i, T const l) {
using limits = std::numeric_limits<I>;

Expand All @@ -56,7 +65,7 @@ std::pair<T, I> periodic_fold(T x, I i, T const l) {
* @param l Length of primary interval
* @return x folded into [0, l).
*/
template <typename T> T periodic_fold(T x, T const l) {
template <FloatingPointOrRef T> T periodic_fold(T x, T const l) {
#ifndef __FAST_MATH__
/* Can't fold if either x or l is nan or inf. */
if (std::isnan(x) or std::isnan(l) or std::isinf(x) or (l == 0)) {
Expand Down

0 comments on commit 08111ba

Please sign in to comment.