53#if !defined(LIBBRAHE_MATHTOOLS_H)
54#define LIBBRAHE_MATHTOOLS_H
61#if defined(__cplusplus)
66#pragma warning (disable: 4244 4267 4996)
67#if !defined(__cplusplus)
69static const int true = 1;
70static const int false = 0;
72typedef unsigned __int64 uint64_t;
73typedef __int64 int64_t;
74typedef unsigned __int32 uint32_t;
75typedef __int32 int32_t;
76typedef unsigned __int16 uint16_t;
77typedef __int16 int16_t;
78typedef unsigned __int8 uint8_t;
308#define BRAHE_E 2.71828182845904523536028747135
311#define BRAHE_LOG2_E 1.44269504088896340735992468100
314#define BRAHE_LOG10_E 0.43429448190325182765112891892
317#define BRAHE_SQRT_2 1.41421356237309504880168872421
320#define BRAHE_SQRT_HALF 0.70710678118654752440084436210
323#define BRAHE_SQRT_3 1.73205080756887729352744634151
326#define BRAHE_PI 3.14159265358979323846264338328
329#define BRAHE_TAU 6.28318530717958647692528676656
332#define BRAHE_PI_DIV_2 1.57079632679489661923132169164
335#define BRAHE_PI_DIV_3 1.04719755119659774615421446109
338#define BRAHE_PI_DIV_4 0.78539816339744830961566084582
341#define BRAHE_PI_DIV_6 0.52359877559829887307710723055
344#define BRAHE_PI_DIV_9 0.34906585039886591538473815370
347#define BRAHE_PI_DIV_12 0.26179938779914943653855361527
350#define BRAHE_PI_DIV_18 0.17453292519943295769236907685
353#define BRAHE_PI_DIV_36 0.08726646259971647884618453842
356#define BRAHE_DEG_PER_RAD 57.2957795130823208767981548141
359#define BRAHE_RAD_PER_DEG 0.01745329251994329576923690768
362#define BRAHE_SQRT_PI 1.77245385090551602729816748334
365#define BRAHE_TWO_DIV_SQRT_PI 1.12837916709551257389615890312
368#define BRAHE_ONE_DIV_PI 0.31830988618379067153776752675
371#define BRAHE_TWO_DIV_PI 0.63661977236758134307553505349
374#define BRAHE_LN_10 2.30258509299404568401799145468
377#define BRAHE_LN_2 0.69314718055994530941723212146
380#define BRAHE_LOG_2 0.30102999566398119521373889472
383#define BRAHE_LN_PI 1.14472988584940017414342735135
386#define BRAHE_EULER 0.57721566490153286060651209008
388#if defined(__cplusplus)
double brahe_log2base(const double x, const double base)
Logarithm to a specified base.
double brahe_round_nearest(const double x)
Round to nearest value.
brahe_pretty_format_t
Formats for pretty-printing integers.
Definition: mathtools.h:156
@ BRAHE_PRETTY_COMMA
comma delimited, (1,234,567,890)
Definition: mathtools.h:160
@ BRAHE_PRETTY_TEXT
english text (nine thousand, two hundred eleven)
Definition: mathtools.h:158
char * brahe_pretty_int(int64_t n, brahe_pretty_format fmt)
Turn a 64-bit integer into a pretty string.
double * brahe_moving_average(const double *data, const int n, const int distance)
Moving average.
int brahe_sizepow2(const int n)
Smallest power of 2 that includes a given value.
uint64_t brahe_lcm(const uint64_t x, const uint64_t y)
Lowest common multiple.
double * brahe_simple_fft2(const double *data, const int n)
Simple real-to-real fft (power of 2 length)
double brahe_sigdig(const double x, const uint16_t n)
Set number of significant digits in a floating-point value.
double brahe_asinh(const double x)
Hyperbolic arcsine.
double brahe_acosh(const double x)
Hyperbolic arccosine.
struct brahe_statistics_t brahe_statistics
Structure containing statistical values calculate from a double array.
double brahe_atanh(const double x)
Hyperbolic arctangent.
double * brahe_simple_fft(const double *data, const int n)
Simple real-to-real fft (arbitrary length)
brahe_statistics brahe_get_statistics(double *data, size_t n)
statistics for array of double
enum brahe_pretty_format_t brahe_pretty_format
Formats for pretty-printing integers.
double * brahe_make_sinusoid(const brahe_wave_factor_t *factors, const size_t factor_n, const size_t array_n)
Sine wave based artificial signal generator.
uint64_t brahe_gcf(uint64_t x, uint64_t y)
Greatest common factor (denominator)
void brahe_add_noise(double *a, const size_t n, double noise)
Apply noise to a signal.
Structure containing statistical values calculate from a double array.
Definition: mathtools.h:179
double min
minimum value from array
Definition: mathtools.h:181
double mean
mean (average)
Definition: mathtools.h:185
double variance
variance
Definition: mathtools.h:187
double max
maximum value
Definition: mathtools.h:183
double sigma
standard deviation
Definition: mathtools.h:189
Sine wave definition.
Definition: mathtools.h:244
double amplitude
arbitrary wave amplitude
Definition: mathtools.h:248
double wavelength
wavelength
Definition: mathtools.h:246