18 #ifndef _biomcmc_lowlevel_h_ 19 #define _biomcmc_lowlevel_h_ 34 #include <sys/times.h> 35 #include <sys/types.h> 50 #define EXP_1 2.71828182845904523536028747135266 55 #if defined(__GNUC__) && __GNUC__ >= 7 56 #define attribute_FALLTHROUGH __attribute__ ((fallthrough)); 58 #define attribute_FALLTHROUGH ((void)0); 61 #define MIN(x,y) (((x)<(y)) ? (x) : (y)) 62 #define MAX(x,y) (((x)>(y)) ? (x) : (y)) 63 #define MOD(a) (((a)>0) ? (a) :(-a)) 67 typedef unsigned char bool;
77 int *
col_mate, *unchosen_row, *slack_row, *row_mate, *parent_row;
78 double **
dcost, initial_dcost, final_dcost;
80 int *row_dec, *col_inc, *slack;
117 int compare_int_decreasing (
const void *a,
const void *b);
118 int compare_uint64_increasing (
const void *a,
const void *b);
119 int compare_uint64_decreasing (
const void *a,
const void *b);
120 int compare_double_increasing (
const void *a,
const void *b);
121 int compare_double_decreasing (
const void *a,
const void *b);
134 uint32_t
biomcmc_levenshtein_distance (
const char *s1, uint32_t n1,
const char *s2, uint32_t n2, uint32_t cost_sub, uint32_t cost_indel,
bool skip_borders);
137 hungarian new_hungarian (
int size,
bool is_double);
138 void hungarian_reset (hungarian p);
139 void hungarian_update_cost (hungarian p,
int row,
int col,
void *cost);
140 void del_hungarian (hungarian p);
141 void hungarian_solve (hungarian p,
int this_size);
int initial_cost
assignment size. Cost is a square matrix, so size should be an overestimate where "missing" nodes are...
Definition: lowlevel.h:74
uint32_t biomcmc_levenshtein_distance(const char *s1, uint32_t n1, const char *s2, uint32_t n2, uint32_t cost_sub, uint32_t cost_indel, bool skip_borders)
edit distance between two sequences (slow), with option to allow one of sequences to terminate soon (...
Definition: lowlevel.c:166
void * biomcmc_realloc(void *ptr, size_t size)
Memory-safe realloc() function.
Definition: lowlevel.c:31
void * biomcmc_malloc(size_t size)
Memory-safe malloc() function.
Definition: lowlevel.c:23
Definition: lowlevel.h:71
void biomcmc_error(const char *template,...)
Prints error message and quits program.
Definition: lowlevel.c:52
FILE * biomcmc_fopen(const char *path, const char *mode)
Memory-safe fopen() function.
Definition: lowlevel.c:39
int compare_int_increasing(const void *a, const void *b)
Comparison between integers, doubles, etc. used by qsort()
Definition: lowlevel.c:67
int biomcmc_getline(char **lineptr, size_t *n, FILE *stream)
read file line-by-line (like homonymous function from GNU C library)
Definition: lowlevel.c:113
double ** dcost
col_mate[row] with column match for row
Definition: lowlevel.h:78
int * col_mate
our final cost is on rescaled cost matrix, therefore to restore the "classical" optimal cost one shou...
Definition: lowlevel.h:77
int final_cost
sum of lowest input cost values for each column. The hungarian method rescales them so that minimum p...
Definition: lowlevel.h:74
unsigned char bool
Mnemonic for boolean (char is smaller than int)
Definition: lowlevel.h:67
int size
cost matrix
Definition: lowlevel.h:74
double * row_dec_d
costs when working with float numbers instead of integers
Definition: lowlevel.h:79