<commit_before>#include <iostream>

#include "nbody/Integrator.h"

void
ForwardEuler::step( ParticleSystem *sys,
                    float          h )
{
  std::vector< Vector3f > X0 = sys->getState();
  std::vector< Vector3f > step = sys->evalF( X0 );
  for ( size_t i = 0; i < X0.size(); i++ )
    X0[i] += h * step[i];
  sys->setState( X0 );
}

void
Trapezoidal::step( ParticleSystem *sys,
                   float          h )
{
  std::vector< Vector3f > X0 = sys->getState();
  std::vector< Vector3f > X1 = sys->getState();
  std::vector< Vector3f > step0 = sys->evalF( X0 );
  for ( size_t i = 0; i < X0.size(); i++ )
    X0[i] += h * step0[i];
  std::vector< Vector3f > step1 = sys->evalF( X0 );
  for ( size_t i = 0; i < X1.size(); i++ )
    X1[i] += h * (step0[i] + step1[i]) / (float) 2.0;
  sys->setState( X1 );
}

void
RK4::step( ParticleSystem *sys,
           float          h )
{
  std::vector< Vector3f > Xi = sys->getState();
  std::vector< Vector3f > Xf = sys->getState();
  std::vector< Vector3f > k1, k2, k3, k4;
  k1 = sys->evalF( Xi );
  k2.reserve( Xi.size() ); k3.reserve( Xi.size() ); k4.reserve( Xi.size() );
  for ( size_t i = 0; i < Xi.size(); i++ )
    Xi[i] += k1[i] * h / 2.0f;
  k2 = sys->evalF( Xi );

  Xi = sys->getState();
  for ( size_t i = 0; i < Xi.size(); i++ )
    Xi[i] += k2[i] * h / 2.0f;<commit_msg> 'float' to 'f'<commit_after>#include <iostream>

#include "nbody/Integrator.h"

void
ForwardEuler::step( ParticleSystem *sys,
                    float          h )
{
  std::vector< Vector3f > X0 = sys->getState();
  std::vector< Vector3f > step = sys->evalF( X0 );
  for ( size_t i = 0; i < X0.size(); i++ )
    X0[i] += h * step[i];
  sys->setState( X0 );
}

void
Trapezoidal::step( ParticleSystem *sys,
                   float          h )
{
  std::vector< Vector3f > X0 = sys->getState();
  std::vector< Vector3f > X1 = sys->getState();
  std::vector< Vector3f > step0 = sys->evalF( X0 );
  for ( size_t i = 0; i < X0.size(); i++ )
    X0[i] += h * step0[i];
  std::vector< Vector3f > step1 = sys->evalF( X0 );
  for ( size_t i = 0; i < X1.size(); i++ )
    X1[i] += h * (step0[i] + step1[i]) / 2.0f;
  sys->setState( X1 );
}

void
RK4::step( ParticleSystem *sys,
           float          h )
{
  std::vector< Vector3f > Xi = sys->getState();
  std::vector< Vector3f > Xf = sys->getState();
  std::vector< Vector3f > k1, k2, k3, k4;
  k1 = sys->evalF( Xi );
  k2.reserve( Xi.size() ); k3.reserve( Xi.size() ); k4.reserve( Xi.size() );
  for ( size_t i = 0; i < Xi.size(); i++ )
    Xi[i] += k1[i] * h / 2.0f;
  k2 = sys->evalF( Xi );

  Xi = sys->getState();
  for ( size_t i = 0; i < Xi.size(); i++ )
    Xi[i] += k2[i] * h / 2.0f;
{'fraction_non_alphanumeric': 0.20872158032053673, 'fraction_numerical': 0.0380171449869549, 'mean_word_length': 2.5084967320261438, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1157490', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1135, 'n_words': 273}