<commit_before>/*
  Wrappers around the C integration code for planar Orbits
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <bovy_symplecticode.h>
#include <bovy_rk.h>
//Potentials
#include <galpy_potentials.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/*
  Function Declarations
*/
void evalPlanarRectForce(double, double *, double *,
			 int, struct leapFuncArg *);
void evalPlanarRectDeriv(double, double *, double *,
			 int, struct leapFuncArg *);
double calcPlanarRforce(double, double, double, 
			int, struct leapFuncArg *);
double calcPlanarphiforce(double, double, double, 
			int, struct leapFuncArg *);
/*
  Actual functions
*/
void integratePlanarOrbit(double *yo,
			  int nt, 
			  double *t,
			  int npot,
			  int * pot_type,
			  double * pot_args,
			  double rtol,
			  double atol,
			  double *result,
			  int odeint_type){
  //Set up the forces, first count
  int ii, jj;
  int dim;
  struct leapFuncArg * leapFuncArgs= (struct leapFuncArg *) malloc ( npot * sizeof (struct leapFuncArg) );
  for (ii=0; ii < npot; ii++){
    switch ( *pot_type++ ) {
    case 0: //LogarithmicHaloPotential, 2 arguments
      leapFuncArgs->planarRforce= &LogarithmicHaloPotentialPlanarRforce;
      leapFuncArgs->planarphiforce= &ZeroPlanarForce;
      leapFuncArgs->nargs= 2;
      break;
    case 1: //DehnenBarPotential, 7 arguments
      leapFuncArgs->planarRforce= &DehnenBarPotentialRforce;
      leapFuncArgs->planarphiforce= &DehnenBarPotentialphiforce;
      leapFuncArgs->nargs= 7;
      break;
    case 2: //TransientLogSpiralPotential, 8 arguments
      leapFuncArgs->planarRforce= &TransientLogSpiralPotentialRforce;
      leapFuncArgs->planarphiforce= &TransientLogSpiralPotentialphiforce;
      leapFuncArgs->nargs= 8;
      break;
    case 3: //SteadyLogSpiralPotential, 8 arguments
      leapFuncArgs->planarRforce= &SteadyLogSpiralPotentialRforce;
      leapFuncArgs->planarphiforce= &SteadyLogSpiralPotentialphiforce;
      leapFuncArgs->nargs= 8;
      break;
    }
    leapFuncArgs->args= (double *) malloc( leapFuncArgs->nargs * sizeof(double));
    for (jj=0; jj < leapFuncArgs->nargs; jj++){
      *(leapFuncArgs->args)= *pot_args++;
      leapFuncArgs->args++;
    }
    leapFuncArgs->args-= leapFuncArgs->nargs;
    leapFuncArgs++;
  }
  leapFuncArgs-= npot;
  //Integrate
  void (*odeint_func)(void (*func)(double, double *, double *,
			   int, struct leapFuncArg *),<commit_msg>add EllipticalDiskPotential to C integrator<commit_after>/*
  Wrappers around the C integration code for planar Orbits
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <bovy_symplecticode.h>
#include <bovy_rk.h>
//Potentials
#include <galpy_potentials.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/*
  Function Declarations
*/
void evalPlanarRectForce(double, double *, double *,
			 int, struct leapFuncArg *);
void evalPlanarRectDeriv(double, double *, double *,
			 int, struct leapFuncArg *);
double calcPlanarRforce(double, double, double, 
			int, struct leapFuncArg *);
double calcPlanarphiforce(double, double, double, 
			int, struct leapFuncArg *);
/*
  Actual functions
*/
void integratePlanarOrbit(double *yo,
			  int nt, 
			  double *t,
			  int npot,
			  int * pot_type,
			  double * pot_args,
			  double rtol,
			  double atol,
			  double *result,
			  int odeint_type){
  //Set up the forces, first count
  int ii, jj;
  int dim;
  struct leapFuncArg * leapFuncArgs= (struct leapFuncArg *) malloc ( npot * sizeof (struct leapFuncArg) );
  for (ii=0; ii < npot; ii++){
    switch ( *pot_type++ ) {
    case 0: //LogarithmicHaloPotential, 2 arguments
      leapFuncArgs->planarRforce= &LogarithmicHaloPotentialPlanarRforce;
      leapFuncArgs->planarphiforce= &ZeroPlanarForce;
      leapFuncArgs->nargs= 2;
      break;
    case 1: //DehnenBarPotential, 7 arguments
      leapFuncArgs->planarRforce= &DehnenBarPotentialRforce;
      leapFuncArgs->planarphiforce= &DehnenBarPotentialphiforce;
      leapFuncArgs->nargs= 7;
      break;
    case 2: //TransientLogSpiralPotential, 8 arguments
      leapFuncArgs->planarRforce= &TransientLogSpiralPotentialRforce;
      leapFuncArgs->planarphiforce= &TransientLogSpiralPotentialphiforce;
      leapFuncArgs->nargs= 8;
      break;
    case 3: //SteadyLogSpiralPotential, 8 arguments
      leapFuncArgs->planarRforce= &SteadyLogSpiralPotentialRforce;
      leapFuncArgs->planarphiforce= &SteadyLogSpiralPotentialphiforce;
      leapFuncArgs->nargs= 8;
      break;
    case 4: //EllipticalDiskPotential, 6 arguments
      leapFuncArgs->planarRforce= &EllipticalDiskPotentialRforce;
      leapFuncArgs->planarphiforce= &EllipticalDiskPotentialphiforce;
      leapFuncArgs->nargs= 6;
      break;
    }
    leapFuncArgs->args= (double *) malloc( leapFuncArgs->nargs * sizeof(double));
    for (jj=0; jj < leapFuncArgs->nargs; jj++){
      *(leapFuncArgs->args)= *pot_args++;
      leapFuncArgs->args++;
    }
    leapFuncArgs->args-= leapFuncArgs->nargs;
    leapFuncArgs++;
  }
  leapFuncArgs-= npot;
  //Integrate
  void (*odeint_func)(void (*func)(double, double *, double *,
			   int, struct leapFuncArg *),
{'fraction_non_alphanumeric': 0.11322568242983468, 'fraction_numerical': 0.014033064206074588, 'mean_word_length': 3.844506517690875, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 58, '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': '7385399', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1801, 'n_words': 390}