#include #include long factorial(int n) { int res=1 ; for (int i=2; i<=n; i++) res*=i ; return res ; } long nchoosek(int n, int k) { long res=1 ; for (int i=n-k+1; i<=n; i++) res*=i ; return res/factorial(k) ; } double compute(char *avec, int alen, char* bvec, int blen, int degree, int max_mismatch, double* weights) { double sum=0; assert(alen==blen) ; int *match_vector=new int[alen] ; for (int i=0; imax_mismatch) break ; } ; sum += weights[j+degree*mismatches]; } } delete[] match_vector ; return (double) sum ; } double compute_normalized(char *avec, int alen, char* bvec, int blen, int degree, int max_mismatch) { /* you may want to precompute this ...*/ double* weights=new double[degree*(1+max_mismatch)]; double sum=0; for (int i=0; i