STATUS: unstable Additional math-functions. More...
#include <stdlib.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include <string.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_sf_bessel.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_cblas.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include "helper.h"
#include "definitions.h"
#include "complex.h"
Go to the source code of this file.
Defines | |
#define | _ISOC99_SOURCE |
#define | ABS(a) ( ((a)<0) ? (-1*(a)) : (a) ) |
absolute value of a number | |
#define | CHECK_BIT(var, pos) ((var) & (1<<(pos))) |
check whether bit at position pos is 1. | |
#define | ISODD(x) ((((x)%2)==0)? (0) : (1)) |
#define | MAX(a, b) ((a) > (b) ? (a):(b)) |
maximum of two elements. | |
#define | MIN(a, b) ((a) < (b) ? (a):(b)) |
minimum of two elements. | |
#define | PI 3.14159265358979323846 |
#define | SQR(a) ((a)*(a)) |
square of a number. | |
Functions | |
int | abscmp (const void *p1, const void *p2) |
int | closest_index (const double *v, int n, double c) |
int | cmpdouble (double d1, double d2, int precision) |
double * | dblp_complex_to_real (const Complex *vc, double *vr, int n) |
double | dblp_euclidean_distance (const double *v1, const double *v2, int n) |
double * | dblp_init (double *v, int n, double val) |
double | dblp_max (double *v, int n, int *idx) |
double | dblp_mean (double *v, int n) |
double | dblp_min (double *v, int n, int *idx) |
void | dblp_minus_scalar (double *v, int n, double val) |
void | dblp_print (double *v, int n) |
void | dblp_print_int (int *v, int n) |
void | dblp_shuffle_int (int *permut, int n) |
void | dblpp_add_dblpp (double **m1, const double **m2, int N, int n) |
void | dblpp_add_scalar (double **m, int N, int n, double s) |
void | dblpp_copy (const double **src, double **dest, int N, int M) |
double ** | dblpp_delcol (double **m, int N, int n, int col) |
double ** | dblpp_delrow (double **m, int N, int n, int row) |
void | dblpp_divide_scalar (double **m, int N, int n, double s) |
void | dblpp_dottimes_dblpp (double **m1, const double **m2, int N, int M) |
void | dblpp_free (double **m, int N) |
double ** | dblpp_init (int N, int M) |
int ** | dblpp_init_int (int N, int M) |
double | dblpp_max (const double **m, int N, int n, int *i1, int *i2) |
double | dblpp_min (const double **m, int N, int n, int *i1, int *i2) |
void | dblpp_mul_scalar (double **m, int N, int n, double s) |
void | dblpp_normalize_by_max (double **m, int M, int N) |
void | dblpp_print (const double **m, int N, int n) |
double ** | dblpp_rand (double **m, int N, int M, double lower, double upper) |
void | dblpp_sub_dblpp (double **dest, const double **src, int N, int n) |
double | drawsample_nearest_neighbour (const double *v, int n, double x) |
Complex * | expand_polynomial_from_roots (const Complex *roots, int n, Complex *coeffs) |
void | fft (double *data, unsigned long nn, int isign) |
double * | flip_array (double *v, int n) |
double | gaussian (double x, double sigma, double mu) |
double | glog (double v, int b) |
int | iremainder (double x, double y) |
double * | lininterp (const double *x1, const double *y1, int n1, const double *x2, double *y2, int n2) |
int * | linspace (int first, int last) |
double * | linspace_dbl (double first, double last, double step, double *v, int *n) |
double | mad (const double *data, int n) |
double | maxel (double *v, int n) |
int | maxeli (int *v, int n) |
int | next_pow2 (int n) |
double * | resample_gsl (const double *s, int n, int newn, double *news, const gsl_interp_type *method) |
double * | resample_linear (const double *s, int n, int newn, double *news) |
double * | resample_nearest_neighbour (const double *s, int n, int newn, double *news) |
double | rmse (const double *r, const double *d, int n) |
double * | sampled_line (double *ntimes, int n, double start, double end) |
void | scalar_minus_dblpp (double scalar, double **m, int N, int M) |
int | sgn (int x) |
double * | sigext_smooth (double *data, int ns, int n) |
double * | sigext_sym (double *data, int ns, int n) |
double * | sigext_zeros (double *data, int ns, int n) |
double * | sigext_zerosr (double *data, int ns, int n) |
double | snr (const double *r, const double *d, int n) |
void | swap2d (double *v1, double *v2) |
void | swap2i (int *v1, int *v2) |
double | vnorm (const double *v, int n, int p) |
double | weighted_median_from_unsorted (const double *d, const double *w, int n) |
STATUS: unstable Additional math-functions.
Definition in file mathadd.h.
#define ABS | ( | a | ) | ( ((a)<0) ? (-1*(a)) : (a) ) |
#define CHECK_BIT | ( | var, | ||
pos | ||||
) | ((var) & (1<<(pos))) |
#define MAX | ( | a, | ||
b | ||||
) | ((a) > (b) ? (a):(b)) |
#define MIN | ( | a, | ||
b | ||||
) | ((a) < (b) ? (a):(b)) |
int closest_index | ( | const double * | v, | |
int | n, | |||
double | c | |||
) |
int cmpdouble | ( | double | d1, | |
double | d2, | |||
int | precision | |||
) |
Compare two doubles to a certain precision. cmpdouble()
precision | to which position after comma it is compared |
double* dblp_complex_to_real | ( | const Complex * | vc, | |
double * | vr, | |||
int | n | |||
) |
double dblp_euclidean_distance | ( | const double * | v1, | |
const double * | v2, | |||
int | n | |||
) |
double* dblp_init | ( | double * | v, | |
int | n, | |||
double | val | |||
) |
double dblp_max | ( | double * | v, | |
int | n, | |||
int * | idx | |||
) |
double dblp_min | ( | double * | v, | |
int | n, | |||
int * | idx | |||
) |
void dblp_minus_scalar | ( | double * | v, | |
int | n, | |||
double | val | |||
) |
void dblp_shuffle_int | ( | int * | permut, | |
int | n | |||
) |
void dblpp_add_dblpp | ( | double ** | m1, | |
const double ** | m2, | |||
int | N, | |||
int | n | |||
) |
void dblpp_add_scalar | ( | double ** | m, | |
int | N, | |||
int | n, | |||
double | s | |||
) |
void dblpp_copy | ( | const double ** | src, | |
double ** | dest, | |||
int | N, | |||
int | M | |||
) |
double** dblpp_delcol | ( | double ** | m, | |
int | N, | |||
int | n, | |||
int | col | |||
) |
double** dblpp_delrow | ( | double ** | m, | |
int | N, | |||
int | n, | |||
int | row | |||
) |
void dblpp_divide_scalar | ( | double ** | m, | |
int | N, | |||
int | n, | |||
double | s | |||
) |
void dblpp_dottimes_dblpp | ( | double ** | m1, | |
const double ** | m2, | |||
int | N, | |||
int | M | |||
) |
double** dblpp_init | ( | int | N, | |
int | M | |||
) |
int** dblpp_init_int | ( | int | N, | |
int | M | |||
) |
double dblpp_max | ( | const double ** | m, | |
int | N, | |||
int | n, | |||
int * | i1, | |||
int * | i2 | |||
) |
double dblpp_min | ( | const double ** | m, | |
int | N, | |||
int | n, | |||
int * | i1, | |||
int * | i2 | |||
) |
void dblpp_mul_scalar | ( | double ** | m, | |
int | N, | |||
int | n, | |||
double | s | |||
) |
void dblpp_normalize_by_max | ( | double ** | m, | |
int | M, | |||
int | N | |||
) |
void dblpp_print | ( | const double ** | m, | |
int | N, | |||
int | n | |||
) |
double** dblpp_rand | ( | double ** | m, | |
int | N, | |||
int | M, | |||
double | lower, | |||
double | upper | |||
) |
void dblpp_sub_dblpp | ( | double ** | dest, | |
const double ** | src, | |||
int | N, | |||
int | n | |||
) |
double drawsample_nearest_neighbour | ( | const double * | v, | |
int | n, | |||
double | x | |||
) |
void fft | ( | double * | data, | |
unsigned long | nn, | |||
int | isign | |||
) |
1D Fourier transform (FFT). Taken from Numerical Recipes in C.
data | - array to be tranformed (input/output); for input, is assumed to be complex, i.e. [ real, imag, real, imag, ... ] data contains nn complex numbers and 2*nn entries. | |
nn | - must be a power of two, not checked for!; length(data)=2*nn | |
isign | - 1: forward; -1: ifft; |
int iremainder | ( | double | x, | |
double | y | |||
) |
double* lininterp | ( | const double * | x1, | |
const double * | y1, | |||
int | n1, | |||
const double * | x2, | |||
double * | y2, | |||
int | n2 | |||
) |
int* linspace | ( | int | first, | |
int | last | |||
) |
double* linspace_dbl | ( | double | first, | |
double | last, | |||
double | step, | |||
double * | v, | |||
int * | n | |||
) |
same as first:step:last in matlab. A sequence first, first+step, first+(2*step), ... ,last is computed. The length of this sequence is
v | either enough free allocated space, or ALLOC_IN_FCT (NULL)
| |
n | - number of doubles in v (return value) |
double* resample_gsl | ( | const double * | s, | |
int | n, | |||
int | newn, | |||
double * | news, | |||
const gsl_interp_type * | method | |||
) |
Resample a vector to match a new length using GSL's interpolation options:
Assume that s is from [0,...,n] and resample, such that the new x is running from [0,...,newn] where y[newn]=y_old[n].
s,n | the original vector | |
newn | the new length of the vector | |
news | caller-allocated memory of at least length newn (if NULL, the function allocates own memory) | |
method | one of GSL interpolation types (see above) |
double* resample_linear | ( | const double * | s, | |
int | n, | |||
int | newn, | |||
double * | news | |||
) |
Resample a vector to match a new length (linear interpolation).
s,n | the original vector | |
newn | the new length of the vector | |
news | caller-allocated memory of at least length newn (if NULL, the function allocates own memory) |
double* resample_nearest_neighbour | ( | const double * | s, | |
int | n, | |||
int | newn, | |||
double * | news | |||
) |
Resample a vector to match a new length (NN-interpolation). Assume that s is from [0,...,n] and resample, such that the new x is running from [0,...,newn] where y[newn]=y_old[n].
s,n | the original vector | |
newn | the new length of the vector | |
news | caller-allocated memory of at least length newn (if NULL, the function allocates own memory) |
double* sampled_line | ( | double * | ntimes, | |
int | n, | |||
double | start, | |||
double | end | |||
) |
void scalar_minus_dblpp | ( | double | scalar, | |
double ** | m, | |||
int | N, | |||
int | M | |||
) |
double* sigext_smooth | ( | double * | data, | |
int | ns, | |||
int | n | |||
) |
double* sigext_sym | ( | double * | data, | |
int | ns, | |||
int | n | |||
) |
double* sigext_zeros | ( | double * | data, | |
int | ns, | |||
int | n | |||
) |
double* sigext_zerosr | ( | double * | data, | |
int | ns, | |||
int | n | |||
) |