aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
blob: 6883a169164c545449be7e87416b54ae466bdaab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef INCLUDED_UTILS_H
#define INCLUDED_UTILS_H

#include <stdlib.h>
#include <stdbool.h>
#include <gsl/gsl_spmatrix.h>
#include <assert.h>

#define MALLOC malloc
#define REALLOC realloc
#define FREE free
#define ASSERT assert

#define MIN(A, B) ({    \
      A < B ? A : B;    \
})

#define SWAP(A, B) ({           \
      typeof (A) tmp = (A);     \
      (A) = (B);                \
      (B) = tmp;                \
    })

#define PRINT_EXP(EXP, FMT) printf (#EXP" = "FMT"\n", EXP)

extern void print_gsl_matrix (const gsl_matrix *);
extern void prompt (char *label, char *fmt, void *where);
extern int log10sz (size_t sz);

double gsl_matrix_determinant (const gsl_matrix *);
double gsl_matrix_cofactor    (const gsl_matrix *, size_t i, size_t j);

#endif