Utilities

Utilities — Miscellaneous utilities

Synopsis

#include "utils.h"


void                show_matrix_eqn                     (gsl_matrix *M,
                                                         gsl_vector *v);
enum                AssplodeFlag;
#define             C_VACUO
#define             ELECTRON_CHARGE
#define             ERROR                               (...)
#define             J_to_eV                             (a)
#define             PLANCK
#define             STATUS                              (...)
#define             THOMSON_LENGTH
int                 assplode                            (const char *a,
                                                         const char *delims,
                                                         char ***pbits,
                                                         AssplodeFlag flags);
#define             biggest                             (a,
                                                         b)
char *              check_prefix                        (char *prefix);
void                chomp                               (char *s);
#define             deg2rad                             (a)
#define             eV_to_J                             (a)
double              gaussian_noise                      (gsl_rng *rng,
                                                         double expected,
                                                         double stddev);
char *              safe_basename                       (const char *in);
void                progress_bar                        (int val,
                                                         int total,
                                                         const char *text);
#define             rad2deg                             (a)
#define             is_odd                              (a)
int                 poisson_noise                       (gsl_rng *rng,
                                                         double expected);
size_t              notrail                             (char *s);
#define             smallest                            (a,
                                                         b)
#define             ph_en_to_lambda                     (a)
#define             ph_lambda_to_en                     (a)
#define             ph_eV_to_lambda                     (a)
#define             ph_lambda_to_eV                     (a)
double              random_flat                         (gsl_rng *rng,
                                                         double max);
double              flat_noise                          (gsl_rng *rng,
                                                         double expected,
                                                         double width);
void                show_matrix                         (gsl_matrix *M);
#define             likely                              (x)
#define             unlikely                            (x)
#define             UNUSED

Description

Wibble

Details

show_matrix_eqn ()

void                show_matrix_eqn                     (gsl_matrix *M,
                                                         gsl_vector *v);

Displays a matrix equation of the form M.a = v.

M :

A matrix

v :

A vector

enum AssplodeFlag

typedef enum {
	ASSPLODE_NONE = 0,
	ASSPLODE_DUPS = 1<<0
} AssplodeFlag;

ASSPLODE_NONE

Nothing

ASSPLODE_DUPS

Don't merge deliminators

C_VACUO

#define C_VACUO (299792458)

ELECTRON_CHARGE

#define ELECTRON_CHARGE (1.6021773e-19)

ERROR()

#define             ERROR(...)

J_to_eV()

#define J_to_eV(a) ((a)/ELECTRON_CHARGE)

PLANCK

#define PLANCK (6.62606896e-34)

STATUS()

#define             STATUS(...)

THOMSON_LENGTH

#define THOMSON_LENGTH (2.81794e-15)

assplode ()

int                 assplode                            (const char *a,
                                                         const char *delims,
                                                         char ***pbits,
                                                         AssplodeFlag flags);

biggest()

#define biggest(a,b) ((a>b) ? (a) : (b))

check_prefix ()

char *              check_prefix                        (char *prefix);

chomp ()

void                chomp                               (char *s);

deg2rad()

#define deg2rad(a) ((a)*M_PI/180)

eV_to_J()

#define eV_to_J(a) ((a)*ELECTRON_CHARGE)

gaussian_noise ()

double              gaussian_noise                      (gsl_rng *rng,
                                                         double expected,
                                                         double stddev);

safe_basename ()

char *              safe_basename                       (const char *in);

progress_bar ()

void                progress_bar                        (int val,
                                                         int total,
                                                         const char *text);

rad2deg()

#define rad2deg(a) ((a)*180/M_PI)

is_odd()

#define is_odd(a) ((a)%2==1)

poisson_noise ()

int                 poisson_noise                       (gsl_rng *rng,
                                                         double expected);

notrail ()

size_t              notrail                             (char *s);

smallest()

#define smallest(a,b) ((a<b) ? (a) : (b))

ph_en_to_lambda()

#define ph_en_to_lambda(a) ((PLANCK*C_VACUO)/(a))

ph_lambda_to_en()

#define ph_lambda_to_en(a) ((PLANCK*C_VACUO)/(a))

ph_eV_to_lambda()

#define ph_eV_to_lambda(a) ph_en_to_lambda(eV_to_J(a))

ph_lambda_to_eV()

#define ph_lambda_to_eV(a) J_to_eV(ph_lambda_to_en(a))

random_flat ()

double              random_flat                         (gsl_rng *rng,
                                                         double max);

flat_noise ()

double              flat_noise                          (gsl_rng *rng,
                                                         double expected,
                                                         double width);

show_matrix ()

void                show_matrix                         (gsl_matrix *M);

Displays a matrix.

M :

A matrix

likely()

#define likely(x) __builtin_expect (!!(x), 1)

unlikely()

#define unlikely(x) __builtin_expect (!!(x), 0)

UNUSED

#define UNUSED __attribute__((unused))