<commit_before>#ifndef P2P_TSTEP_KERNEL_H
#define P2P_TSTEP_KERNEL_H

#include"common.h"
#include"smoothing.h"

//
// p2p_tstep_kernel_core
////////////////////////////////////////////////////////////////////////////////
inline REAL
p2p_tstep_kernel_core(REAL iomega,
                      const REAL4 rmi, const REAL4 vei,
                      const REAL4 rmj, const REAL4 vej,
                      const REAL eta)
{
    REAL4 r;
    r.x = rmi.x - rmj.x;                                             // 1 FLOPs
    r.y = rmi.y - rmj.y;                                             // 1 FLOPs
    r.z = rmi.z - rmj.z;                                             // 1 FLOPs
    r.w = rmi.w + rmj.w;                                             // 1 FLOPs
    REAL4 v;
    v.x = vei.x - vej.x;                                             // 1 FLOPs
    v.y = vei.y - vej.y;                                             // 1 FLOPs
    v.z = vei.z - vej.z;                                             // 1 FLOPs
    v.w = vei.w + vej.w;                                             // 1 FLOPs
    REAL r2 = r.x * r.x + r.y * r.y + r.z * r.z;                     // 5 FLOPs
    REAL v2 = v.x * v.x + v.y * v.y + v.z * v.z;                     // 5 FLOPs
    REAL rv = r.x * v.x + r.y * v.y + r.z * v.z;                     // 5 FLOPs

    REAL2 ret = smoothed_inv_r2r3(r2, v.w);                          // 4 FLOPs
    REAL inv_r2 = ret.x;
    REAL inv_r3 = ret.y;

    REAL alpha = v2 * inv_r2;                                        // 1 FLOPs
    REAL beta = 2 * r.w * inv_r3;                                    // 2 FLOPs
    REAL omega2 = alpha + beta;                                      // 1 FLOPs
    REAL omega = sqrt(omega2);                                       // 1 FLOPs
    REAL gamma = 1 + beta / omega2;                                  // 2 FLOPs
    gamma = (r2 > 0) ? (gamma):(0);
    REAL dln_omega = -gamma * rv * inv_r2;                           // 2 FLOPs
    omega += eta * dln_omega;   // factor 1/2 included in 'eta'      // 2 FLOPs

//    iomega = (omega > iomega) ? (omega):(iomega);
    iomega += omega * omega;
    return iomega;<commit_msg>changes the time-step criterion into a more general expression.<commit_after>#ifndef P2P_TSTEP_KERNEL_H
#define P2P_TSTEP_KERNEL_H

#include"common.h"
#include"smoothing.h"

//
// p2p_tstep_kernel_core
////////////////////////////////////////////////////////////////////////////////
inline REAL
p2p_tstep_kernel_core(REAL iomega,
                      const REAL4 rmi, const REAL4 vei,
                      const REAL4 rmj, const REAL4 vej,
                      const REAL eta)
{
    REAL4 r;
    r.x = rmi.x - rmj.x;                                             // 1 FLOPs
    r.y = rmi.y - rmj.y;                                             // 1 FLOPs
    r.z = rmi.z - rmj.z;                                             // 1 FLOPs
    r.w = rmi.w + rmj.w;                                             // 1 FLOPs
    REAL4 v;
    v.x = vei.x - vej.x;                                             // 1 FLOPs
    v.y = vei.y - vej.y;                                             // 1 FLOPs
    v.z = vei.z - vej.z;                                             // 1 FLOPs
    v.w = vei.w + vej.w;                                             // 1 FLOPs
    REAL r2 = r.x * r.x + r.y * r.y + r.z * r.z;                     // 5 FLOPs
    REAL v2 = v.x * v.x + v.y * v.y + v.z * v.z;                     // 5 FLOPs
    REAL rv = r.x * v.x + r.y * v.y + r.z * v.z;                     // 5 FLOPs

    REAL2 ret = smoothed_inv_r2r3(r2, v.w);                          // 4 FLOPs
    REAL inv_r2 = ret.x;
    REAL inv_r3 = ret.y;

    REAL alpha = v2 * inv_r2;                                        // 1 FLOPs
    REAL beta = 2 * r.w * inv_r3;                                    // 2 FLOPs
    REAL omega2 = alpha + beta + 1;                                      // 1 FLOPs
    REAL omega = sqrt(omega2);                                       // 1 FLOPs
    REAL gamma = 1 + (beta-1) / omega2;                                  // 2 FLOPs
    gamma = (r2 > 0) ? (gamma):(0);
    REAL dln_omega = -gamma * rv * inv_r2;                           // 2 FLOPs
    omega += eta * dln_omega;   // factor 1/2 included in 'eta'      // 2 FLOPs

//    iomega = (omega > iomega) ? (omega):(iomega);
    iomega += omega * omega;
    return iomega;
{'fraction_non_alphanumeric': 0.14077448747152618, 'fraction_numerical': 0.02369020501138952, 'mean_word_length': 0.7179186228482003, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 50, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7128447', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1379, 'n_words': 354}