<commit_before>#pragma once

#include <math.h>

#include "pal_base.h"  //need pal types

/* Standard math constants. Seems to be in every math.h */
#if !(defined __USE_BSD || defined __USE_XOPEN || defined __USE_GNU || \
      defined _NEWLIB_VERSION || defined __USE_MISC || \
      (defined __DARWIN_C_LEVEL && __DARWIN_C_LEVEL > 199506L))
#define M_E 2.71828182845904523540        /* e */
#define M_LOG2E 1.44269504088896340740    /* log 2e */
#define M_LOG10E 0.43429448190325182765   /* log 10e */
#define M_LN2 0.69314718055994530942      /* log e2 */
#define M_LN10 2.30258509299404568402     /* log e10 */
#define M_PI 3.14159265358979323846       /* pi */
#define M_PI_2 1.57079632679489661923     /* pi/2 */
#define M_PI_4 0.78539816339744830962     /* pi/4 */
#define M_1_PI 0.31830988618379067154     /* 1/pi */
#define M_2_PI 0.63661977236758134308     /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880    /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440  /* 1/sqrt(2) */
#endif

#ifndef HUGE
#define HUGE ((float)3.40282347e+38)      /*maximum value of float*/
#endif
#ifndef MAXFLOAT
#define MAXFLOAT ((float)3.40282347e+38)  /*maximum value of float*/
#endif
#ifndef MINFLOAT
#define MINFLOAT ((float)1.175494351e-38) /*minimum value of float*/
#endif

/* This define is in newlib's math.h (but nowhere else) */
#ifndef M_SQRT3
#define M_SQRT3 1.732051            /* sqrt(3) */
#endif

/*ADDED MATH CONSTANTS*/
#define M_TC 0.63212055882855767840 /* 1 - 1/e */
#define M_PI2 6.283185              /* pi*2 */
#define M_GOLDEN 1.618034           /* golden ratio */
#define M_1_PI2 0.15915494309189534561    /* 1/(pi*2) */

/*ADDED RECIPROCAL CONSTANTS (AVOID DIVISION AT ALL COST)*/
/*IDEALLY THIS WOULD BE IN THE COMPILER? A BETTER WAY?*/
#define M_DIV3 0.3333333333333333333  /* 1/3 */
#define M_DIV4 0.25                   /* 1/4 */
#define M_DIV5 0.2                    /* 1/5 */
#define M_DIV6 0.1666666666666666666  /* 1/6 */
#define M_DIV7 0.142857143            /* 1/7 */
#define M_DIV8 0.125                  /* 1/8 */
#define M_DIV9 0.1111111111111111111  /* 1/9 */
#define M_DIV10 0.1                   /* 1/10 */
#define M_DIV11 0.090909091           /* 1/11 */
#define M_DIV12 0.0833333333333333333 /* 1/12 */
#define M_DIV13 0.076923077           /* 1/13 */
#define M_DIV14 0.071428571           /* 1/14 */
#define M_DIV15 0.0666666666666666666 /* 1/15 */
#define M_DIV16 0.0625                /* 1/16 */

/*ADDED PHYSICAL CONSTANTS (ADD YOUR FAVORITES:-)*/
#define PH_C 299792458                  /*speed of light (m/s)*/
#define PH_M0 1.2566370614359172950     /*mag permeability (mH/m)*/
#define PH_H ((float)6.62606957e-34)    /*planck constant (J/Hz)*/
#define PH_HBAR ((float)1.05457172e-34) /*diract constant* (J.s/rad)*/
#define PH_K ((float)1.3806488e-23)     /*boltzmann constant (J/K)*/
#define PH_ME ((float)9.10938291e-31)   /*mass of electron (kg)*/
#define PH_MP ((float)1.672614e-27)     /*mass of proton (kg)*/
#define PH_MN ((float)1.674920e-27)     /*mass of neutron (kg)*/
#define PH_EC ((float)1.6021917e-19)    /*charge of electron (C)*/
#define PH_F ((float)9.648670e4)        /*faraday constant (C/mol)*/
#define PH_G ((float)6.6732e-11)        /*gravitational constant (N*m^2/kg^2)*/
#define PH_AVO ((float)6.022169e23)     /*avogadro constant*/

/*computing macros?
 *
 *abs,floor,ceil,round,sign,zsign,sqr,min,max,swap,clamp
 *
 */

/* Get the floor of x */
#define M_FLOOR(x) ((int)((int)x - ((int)x > x)))

/* Normalize theta between -pi and pi */
//#define M_NORMALIZE_RADIANS(theta) (theta - (M_PI*2) * M_FLOOR((theta + M_PI) / (M_PI*2)))
#define M_NORMALIZE_RADIANS(theta) (theta - (M_PI2) * M_FLOOR((theta + M_PI) * M_1_PI2))

/*<commit_msg>Making all constants single precision -avoids heavy conversions -but there should be a better way?<commit_after>#pragma once

#include <math.h>

#include "pal_base.h"  //need pal types

/* Standard math constants. Seems to be in every math.h */
#if !(defined __USE_BSD || defined __USE_XOPEN || defined __USE_GNU || \
      defined _NEWLIB_VERSION || defined __USE_MISC || \
      (defined __DARWIN_C_LEVEL && __DARWIN_C_LEVEL > 199506L))
#define M_E        2.71828182845904523540f    /* e */
#define M_LOG2E    1.44269504088896340740f    /* log 2e */
#define M_LOG10E   0.43429448190325182765f    /* log 10e */
#define M_LN2      0.69314718055994530942f    /* log e2 */
#define M_LN10     2.30258509299404568402f    /* log e10 */
#define M_PI       3.14159265358979323846f    /* pi */
#define M_PI_2     1.57079632679489661923f    /* pi/2 */
#define M_PI_4     0.78539816339744830962f    /* pi/4 */
#define M_1_PI     0.31830988618379067154f    /* 1/pi */
#define M_2_PI     0.63661977236758134308f    /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390f    /* 2/sqrt(pi) */
#define M_SQRT2    1.41421356237309504880f    /* sqrt(2) */
#define M_SQRT1_2  0.70710678118654752440f    /* 1/sqrt(2) */
#endif

#ifndef HUGE
#define HUGE ((float)3.40282347e+38)      /*maximum value of float*/
#endif
#ifndef MAXFLOAT
#define MAXFLOAT ((float)3.40282347e+38)  /*maximum value of float*/
#endif
#ifndef MINFLOAT
#define MINFLOAT ((float)1.175494351e-38)  /*minimum value of float*/
#endif

/* This define is in newlib's math.h (but nowhere else) */
#ifndef M_SQRT3
#define M_SQRT3 1.732051f                  /* sqrt(3) */
#endif

/*ADDED MATH CONSTANTS*/
#define M_TC     0.63212055882855767840f    /* 1 - 1/e */
#define M_PI2    6.283185f                  /* pi*2 */
#define M_GOLDEN 1.618034f                  /* golden ratio */
#define M_1_PI2  0.15915494309189534561f    /* 1/(pi*2) */

/*ADDED RECIPROCAL CONSTANTS (AVOID DIVISION AT ALL COST)*/
/*IDEALLY THIS WOULD BE IN THE COMPILER? A BETTER WAY?*/
#define M_DIV3  0.3333333333333333333f  /* 1/3 */
#define M_DIV4  0.25f                   /* 1/4 */
#define M_DIV5  0.2f                    /* 1/5 */
#define M_DIV6  0.1666666666666666666f  /* 1/6 */
#define M_DIV7  0.142857143f            /* 1/7 */
#define M_DIV8  0.125f                  /* 1/8 */
#define M_DIV9  0.1111111111111111111f  /* 1/9 */
#define M_DIV10 0.1f                    /* 1/10 */
#define M_DIV11 0.090909091f            /* 1/11 */
#define M_DIV12 0.0833333333333333333f  /* 1/12 */
#define M_DIV13 0.076923077f            /* 1/13 */
#define M_DIV14 0.071428571f            /* 1/14 */
#define M_DIV15 0.0666666666666666666f  /* 1/15 */
#define M_DIV16 0.0625f                 /* 1/16 */

/*ADDED PHYSICAL CONSTANTS (ADD YOUR FAVORITES:-)*/
#define PH_C    ((float)299792458)             /*speed of light (m/s)*/
#define PH_M0   ((float)1.2566370614359172950) /*mag permeability (mH/m)*/
#define PH_H    ((float)6.62606957e-34)        /*planck constant (J/Hz)*/
#define PH_HBAR ((float)1.05457172e-34)        /*diract constant* (J.s/rad)*/
#define PH_K    ((float)1.3806488e-23)         /*boltzmann constant (J/K)*/
#define PH_ME   ((float)9.10938291e-31)        /*mass of electron (kg)*/
#define PH_MP   ((float)1.672614e-27)          /*mass of proton (kg)*/
#define PH_MN   ((float)1.674920e-27)          /*mass of neutron (kg)*/
#define PH_EC   ((float)1.6021917e-19)         /*charge of electron (C)*/
#define PH_F    ((float)9.648670e4)            /*faraday constant (C/mol)*/
#define PH_G    ((float)6.6732e-11)            /*gravitational constant (N*m^2/kg^2)*/
#define PH_AVO  ((float)6.022169e23)           /*avogadro constant*/

/*computing macros?
 *
 *abs,floor,ceil,round,sign,zsign,sqr,min,max,swap,clamp
 *
 */

/* Get the floor of x */
#define M_FLOOR(x) ((int)((int)x - ((int)x > x)))

/* Normalize theta between -pi and pi */
//#define M_NORMALIZE_RADIANS(theta) (theta - (M_PI*2) * M_FLOOR((theta + M_PI) / (M_PI*2)))
#define M_NORMALIZE_RADIANS(theta) ((float)(theta - (M_PI2) * M_FLOOR((theta + M_PI) * M_1_PI2)))

/*
{'fraction_non_alphanumeric': 0.14937388193202147, 'fraction_numerical': 0.1939688218757986, 'mean_word_length': 2.732474964234621, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 10, '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': '5351352', 'n_tokens_mistral': 4122, 'n_tokens_neox': 3146, 'n_words': 706}