nissy-classic

Stable branch of nissy
git clone https://git.tronto.net/nissy-classic
Download | Log | Files | Refs | README | LICENSE

utils.h (1510B)


      1 #ifndef UTILS_H
      2 #define UTILS_H
      3 
      4 #include <stdbool.h>
      5 #include <stdint.h>
      6 #include <stdlib.h>
      7 #include <string.h>
      8 
      9 #define POW2TO6             64ULL
     10 #define POW2TO11            2048ULL
     11 #define POW2TO12            4096ULL
     12 #define POW3TO7             2187ULL
     13 #define POW3TO8             6561ULL
     14 #define FACTORIAL4          24ULL
     15 #define FACTORIAL6          720ULL
     16 #define FACTORIAL7          5040ULL
     17 #define FACTORIAL8          40320ULL
     18 #define FACTORIAL12         479001600ULL
     19 #define BINOM12ON4          495ULL
     20 #define BINOM8ON4           70ULL
     21 #define MIN(a,b)            (((a) < (b)) ? (a) : (b))
     22 #define MAX(a,b)            (((a) > (b)) ? (a) : (b))
     23 
     24 void        apply_permutation(int *perm, int *set, int n);
     25 int         binomial(int n, int k);
     26 int         digit_array_to_int(int *a, int n, int b);
     27 int         factorial(int n);
     28 void        index_to_perm(int p, int n, int *r);
     29 void        index_to_subset(int s, int n, int k, int *r);
     30 void        int_to_digit_array(int a, int b, int n, int *r);
     31 void        int_to_sum_zero_array(int x, int b, int n, int *a);
     32 int         invert_digits(int a, int b, int n);
     33 bool        is_perm(int *a, int n);
     34 bool        is_subset(int *a, int n, int k);
     35 int         perm_sign(int *a, int n);
     36 int         perm_to_index(int *a, int n);
     37 int         powint(int a, int b);
     38 int         subset_to_index(int *a, int n, int k);
     39 void        sum_arrays_mod(int *src, int *dst, int n, int m);
     40 void        swap(int *a, int *b);
     41 void        swapu64(uint64_t *a, uint64_t *b);
     42 
     43 #endif