Exemple #1
0
int main()
{
    int n = 1e7;
    printf("initializing v...\n");
    std::vector<double> &v = init_vector(n);
    double *a = &(v[0]);
    clock_t t;
    printf("done.\n");
    t = clock();
    printf("sum0: %f\n", sum0(a, n));
    printf("time: %d\n", clock() - t);
    t = clock();
    printf("sum1: %f\n", sum1(v));
    printf("time: %d\n", clock() - t);
    t = clock();
    printf("sum2: %f\n", sum2(v));
    printf("time: %d\n", clock() - t);
    t = clock();
    printf("sum3: %f\n", sum3(v));
    printf("time: %d\n", clock() - t);
    t = clock();
    printf("sum4: %f\n", sum4(v));
    printf("time: %d\n", clock() - t);
    return 0;
}
void printLineOfProbs(int his[hisSize][4], DNA base)
{
int baseVal = ntVal[base];
int i;
double ratio;

printf("%c[] = { ", base);
for (i=0; i<hisSize; ++i)
    {
    ratio = (double) his[i][baseVal] / sum4(his[i]);
    printf("%4.3f, ", ratio);
    }
printf("};\n");
}
void printLineOfHis(int his[hisSize][4], DNA base)
{
int baseVal = ntVal[base];
int i;
long millis;

printf("%c ", base);
for (i=0; i<hisSize; ++i)
    {
    millis = his[i][baseVal] * 1000 / sum4(his[i]);
    if (millis >= 10)
	printf("%3d%% ", (millis+5)/10);
    else
	printf("%d.%d%% ", millis/10, millis%10);
    }
printf("<BR>\n");
}
Exemple #4
0
void printLineOfHis(FILE *f, int his[totSize][5], DNA base, int start, int size)
/* Print a single line of histogram. */
{
int baseVal = ntVal[base];
int i;
long millis;

fprintf(f, "%c ", base);
for (i=start; i<start+size; ++i)
    {
    millis = his[i][baseVal] * 1000 / sum4(his[i]);
    if (millis >= 10)
	fprintf(f, "%3d%% ", (millis+5)/10);
    else
	fprintf(f, "%d.%d%% ", millis/10, millis%10);
    }
fprintf(f, "\n");
}
Exemple #5
0
void CoifCoefTests()
{
    wave_object obj;
    double epsilon = 1e-15;
    double t1,t2,t3,t4,t5;
    std::vector<std::string > waveletNames;
    waveletNames.resize(17);
    for (unsigned int i = 0; i < waveletNames.size(); i++)
    {
        waveletNames[i] = std::string("coif") + patch::to_string(i + 1);
    }

    for (unsigned int j = 0; j < waveletNames.size(); j++)
    {
        char * name = new char[waveletNames[j].size() + 1];
        memcpy(name, waveletNames[j].c_str(), waveletNames[j].size() + 1);
        obj = wave_init(name);// Initialize the wavelet
        t1 = sum1(obj->lpr, obj->lpr_len) - sqrt(2.0);
        t2 = sum2(obj->lpr, obj->lpr_len) - 1. / sqrt(2.0);
        t3 = sum3(obj->lpr, obj->lpr_len) - 1. / sqrt(2.0);
        t4 = sum4(obj->lpr, obj->lpr_len) - 1.;
        
        if (fabs(t1) > epsilon || fabs(t2) > epsilon || fabs(t3) > epsilon || fabs(t4) > epsilon) {
			printf("\n ERROR : Coif Coefficients Unit Test Failed. Exiting. \n");
			exit(-1);
		}
        
        for (int m = 1; m < (obj->lpr_len / 2) - 1;m++) {
			t5 = sum5(obj->lpr, obj->lpr_len, m);
            if (fabs(t5) > epsilon) {
				printf("\n ERROR : Coif Coefficients Unit Test Failed. Exiting. \n");
				exit(-1);
			}
		}
        wave_free(obj);
        delete[] name;
    }
}
Exemple #6
0
int main()
{
    std::cout << sum4(2,3,4,5);
    return 0 ;
}