#ifndef TEMPLATES_H_ #define TEMPLATES_H_ #include "headers.h" #define MM 0 #define GapM 1 #define MX 2 #define XX 3 #define MY 4 #define YY 5 //#define MROWS 500 //#define MCOLS 1000 #define CAT(X,Y) X####Y #define CONCAT(X,Y) CAT(X,Y) #define ALIGNED __attribute__((aligned(32))) typedef union __attribute__((aligned(32))) { ALIGNED __m256 ALIGNED d; ALIGNED __m128i ALIGNED s[2]; ALIGNED float ALIGNED f[8]; ALIGNED __m256i ALIGNED i; } ALIGNED mix_F ALIGNED; typedef union __attribute__((aligned(32))) { ALIGNED __m128 ALIGNED d; ALIGNED __m64 ALIGNED s[2]; ALIGNED float ALIGNED f[4]; ALIGNED __m128i ALIGNED i; } ALIGNED mix_F128 ALIGNED; typedef union ALIGNED { __m128i vec ; __m128 vecf ; uint32_t masks[4] ; } MaskVec_F ; typedef union ALIGNED { __m64 vec ; __m64 vecf ; uint32_t masks[2] ; } MaskVec_F128 ; typedef union ALIGNED { ALIGNED __m128i ALIGNED i; ALIGNED __m128 ALIGNED f; } ALIGNED IF_128f ALIGNED; typedef union ALIGNED { ALIGNED int ALIGNED i; ALIGNED float ALIGNED f; } ALIGNED IF_32 ALIGNED; typedef union __attribute__((aligned(32))) { ALIGNED __m256d ALIGNED d; ALIGNED __m128i ALIGNED s[2]; ALIGNED double ALIGNED f[4]; ALIGNED __m256i ALIGNED i; } ALIGNED mix_D ALIGNED; typedef union __attribute__((aligned(32))) { ALIGNED __m128d ALIGNED d; ALIGNED __m64 ALIGNED s[2]; ALIGNED double ALIGNED f[2]; ALIGNED __m128i ALIGNED i; } ALIGNED mix_D128 ALIGNED; typedef union ALIGNED { __m128i vec ; __m128d vecf ; uint64_t masks[2] ; } MaskVec_D ; typedef union ALIGNED { __m64 vec ; __m64 vecf ; uint64_t masks[1] ; } MaskVec_D128 ; typedef union ALIGNED { ALIGNED __m128i ALIGNED i; ALIGNED __m128d ALIGNED f; } ALIGNED IF_128d ALIGNED; typedef union ALIGNED { ALIGNED int64_t ALIGNED i; ALIGNED double ALIGNED f; } ALIGNED IF_64 ALIGNED; template struct Context{}; template<> struct Context { Context() { for (int x = 0; x < 128; x++) ph2pr[x] = pow(10.0, -((double)x) / 10.0); INITIAL_CONSTANT = ldexp(1.0, 1020.0); LOG10_INITIAL_CONSTANT = log10(INITIAL_CONSTANT); RESULT_THRESHOLD = 0.0; } double LOG10(double v){ return log10(v); } static double _(double n){ return n; } static double _(float n){ return ((double) n); } double ph2pr[128]; double INITIAL_CONSTANT; double LOG10_INITIAL_CONSTANT; double RESULT_THRESHOLD; }; template<> struct Context { Context() { for (int x = 0; x < 128; x++) { ph2pr[x] = powf(10.f, -((float)x) / 10.f); } INITIAL_CONSTANT = ldexpf(1.f, 120.f); LOG10_INITIAL_CONSTANT = log10f(INITIAL_CONSTANT); RESULT_THRESHOLD = ldexpf(1.f, -110.f); } float LOG10(float v){ return log10f(v); } static float _(double n){ return ((float) n); } static float _(float n){ return n; } float ph2pr[128]; float INITIAL_CONSTANT; float LOG10_INITIAL_CONSTANT; float RESULT_THRESHOLD; }; typedef struct { int rslen, haplen; /*int *q, *i, *d, *c;*/ /*int q[MROWS], i[MROWS], d[MROWS], c[MROWS];*/ char *q, *i, *d, *c; char *hap, *rs; int *ihap; int *irs; } testcase; int normalize(char c); int read_testcase(testcase *tc, FILE* ifp=0); #define MIN_ACCEPTED 1e-28f #define NUM_DISTINCT_CHARS 5 #define AMBIG_CHAR 4 class ConvertChar { static uint8_t conversionTable[255] ; public: static void init() { assert (NUM_DISTINCT_CHARS == 5) ; assert (AMBIG_CHAR == 4) ; conversionTable['A'] = 0 ; conversionTable['C'] = 1 ; conversionTable['T'] = 2 ; conversionTable['G'] = 3 ; conversionTable['N'] = 4 ; } static inline uint8_t get(uint8_t input) { return conversionTable[input] ; } }; #endif