Skip to content
Snippets Groups Projects
Commit a412eac3 authored by yejoon's avatar yejoon
Browse files

modify test.c

parent c01fbc0c
No related branches found
No related tags found
No related merge requests found
#include <stdio.h> #include <stdio.h>
#include "fx_s1615_double.h" #include "fx_s1615_double.h"
#include "fx_1615_longlong.h" #include "fx_1615_longlong.h"
//#include <time.h>
#include <limits.h>
//static void fx_1615_longlong_mul1_test(void);
//static void fx_1615_longlong_mul2_test(void);
//static void fx_1615_longlong_mul3_test(void);
//
//static void fx_1615_longlong_mul1_test(void) {
// fx_s1615 divisor = 62764;
// fx_s1615 a = 0;
// int i=0;
// for (i = 0; i < 100000000; ++i) {
// a = FX_1615_LONGLONG_MUL1((i), (divisor));
// }
//}
//
//static void fx_1615_longlong_mul2_test(void) {
// fx_s1615 divisor = 62764;
// fx_s1615 a = 0;
// int i=0;
// for (i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_MUL2((i), (divisor));
// }
//}
//
//static void fx_1615_longlong_mul3_test(void) {
// fx_s1615 divisor = 62764;
// fx_s1615 a = 0;
// int i=0;
// for ( i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_MUL3((i), (divisor));
// }
//}
//
//static void fx_1615_longlong_div01_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// int i=0;
// for (i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV01((i),(divisor));
// }
//}
//
//static void fx_1615_longlong_div02_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// int i=0;
// for ( i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV02((i),(divisor));
// }
//}
//
//static void fx_1615_longlong_div03_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// int i=0;
// for ( i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV03((i),(divisor));
// }
//}
// static void fx_1615_longlong_div04_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV04((i),(divisor));
// }
// }
// static void fx_1615_longlong_div05_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV05((i),(divisor));
// }
// }
// static void fx_1615_longlong_div06_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV06((i),(divisor));
// }
// }
// static void fx_1615_longlong_div07_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV07((i),(divisor));
// }
// }
// static void fx_1615_longlong_div08_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV08((i),(divisor));
// }
// }
// static void fx_1615_longlong_div09_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV09((i),(divisor));
// }
// }
// static void fx_1615_longlong_div10_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV10((i),(divisor));
// }
// }
// static void fx_1615_longlong_div11_test(void) {
// fx_s1615 divisor = 3194858;
// fx_s1615 a = 0;
// for (int i = 0; i < 100000000; ++i) {
// a=FX_1615_LONGLONG_DIV11((i),(divisor));
// }
// }
int main(void) { static void fx_1615_double_mul_test(void) {
// const fx_s1615 fx_1615_SinTable[91] = { 0, 571, 1143, 1714, 2285, 2855, fx_s1615 divisor = 62764;
// 3425, 3993, 4560, 5126, 5690, 6252, 6812, 7371, 7927, 8480, 9032, fx_s1615 a = 0;
// 9580, 10125, 10668, 11207, 11743, 12275, 12803, 13327, 13848, int i=0;
// 14364, 14876, 15383, 15886, 16384, 16876, 17364, 17846, 18323, for (i = 0; i < 100000000; ++i) {
// 18794, 19260, 19720, 20173, 20621, 21062, 21497, 21926, 22347, a = FX_S1615_MUL((i), (divisor));
// 22762, 23170, 23571, 23964, 24351, 24730, 25101, 25465, 25821, }
// 26169, 26509, 26841, 27165, 27481, 27788, 28087, 28377, 28659, }
// 28932, 29196, 29451, 29697, 29935, 30163, 30381, 30591, 30791,
// 30982, 31164, 31336, 31498, 31651, 31794, 31928, 32051, 32165,
// 32270, 32364, 32449, 32523, 32588, 32643, 32688, 32723, 32748, static void fx_1615_longlong_mul1_test(void) {
// 32763, 32768 fx_s1615 divisor = 62764;
// }; fx_s1615 a = 0;
int i=0;
// fx_1615_longlong_mul1_test(); for (i = 0; i < 100000000; ++i) {
// fx_1615_longlong_mul2_test(); a = FX_1615_LONGLONG_MUL1((i), (divisor));
// fx_1615_longlong_mul3_test(); }
// }
//
// fx_1615_longlong_div01_test(); static void fx_1615_longlong_mul2_test(void) {
// fx_1615_longlong_div02_test(); fx_s1615 divisor = 62764;
// fx_1615_longlong_div03_test(); fx_s1615 a = 0;
// fx_1615_longlong_div04_test(); int i=0;
// fx_1615_longlong_div05_test(); for (i = 0; i < 100000000; ++i) {
// fx_1615_longlong_div06_test(); a=FX_1615_LONGLONG_MUL2((i), (divisor));
// fx_1615_longlong_div07_test(); }
// fx_1615_longlong_div08_test(); }
// fx_1615_longlong_div09_test();
// fx_1615_longlong_div10_test(); static void fx_1615_longlong_mul3_test(void) {
// fx_1615_longlong_div11_test(); fx_s1615 divisor = 62764;
fx_s1615 a = 0;
int i=0;
/* for ( i = 0; i < 100000000; ++i) {
for (int i = 0; i < 10; ++i) { a=FX_1615_LONGLONG_MUL3((i), (divisor));
fx_s1615 k = 0x50000; }
fx_s1615 in; }
scanf("%x", &in);
static void fx_1615_double_test(void) {
printf("DIV1: %x\n", (fx_s1615)FX_1615_LONGLONG_DIV1(k, in)); fx_s1615 divisor = 3194858;
printf("DIV2: %x\n", (fx_s1615)FX_1615_LONGLONG_DIV2(k, in)); fx_s1615 a = 0;
printf("DIV3: %x\n", (fx_s1615)FX_1615_LONGLONG_DIV3(k, in)); int i=0;
for (i = 0; i < 100000000; ++i) {
a=FX_S1615_DIV((i),(divisor));
} }
*/ }
static void fx_1615_longlong_div01_test(void) {
fx_s1615 divisor = 3194858;
fx_s1615 a = 0;
int i=0;
for (i = 0; i < 100000000; ++i) {
a=FX_1615_LONGLONG_DIV01((i),(divisor));
}
}
static void fx_1615_longlong_div02_test(void) {
fx_s1615 divisor = 3194858;
fx_s1615 a = 0;
int i=0;
for ( i = 0; i < 100000000; ++i) {
a=FX_1615_LONGLONG_DIV02((i),(divisor));
}
}
static void fx_1615_longlong_div03_test(void) {
fx_s1615 divisor = 3194858;
fx_s1615 a = 0;
int i=0;
for ( i = 0; i < 100000000; ++i) {
a=FX_1615_LONGLONG_DIV03((i),(divisor));
}
}
int main(void) {
#ifdef MULTIPLE_TIME_TEST
fx_1615_double_mul_test();
fx_1615_longlong_mul1_test();
fx_1615_longlong_mul2_test();
fx_1615_longlong_mul3_test();
#endif
#ifdef DIVISION_TIME_TEST
fx_1615_double_test();
fx_1615_longlong_div01_test();
fx_1615_longlong_div02_test();
fx_1615_longlong_div03_test();
#endif
// 20.08.16 sine 함수 테스트 // 20.08.16 sine 함수 테스트
/* #ifdef SIN_PRECISION_TEST
fx_s1615 fa1 = 0x002D0000; fx_s1615 fa1 = 0x002D0000;
fx_s1615 fa2 = 0x00590000; fx_s1615 fa2 = 0x00590000;
fx_s1615 fa3 = 0x00B40000; fx_s1615 fa3 = 0x00B40000;
...@@ -185,8 +109,10 @@ int main(void) { ...@@ -185,8 +109,10 @@ int main(void) {
puts(""); puts("");
} }
} }
*/ #endif
#ifdef FX_MUL_TEST
double da; double da;
double db; double db;
scanf("%lf %lf",&da, &db); scanf("%lf %lf",&da, &db);
...@@ -197,6 +123,10 @@ int main(void) { ...@@ -197,6 +123,10 @@ int main(void) {
printf("Test multiplication\n"); printf("Test multiplication\n");
fc = FX_S1615_MUL(fa, fb);
printf("Exact answer = %f func result = %f, error = %f\n",da*db, FX_S1615_INT_TO_DOUBLE(fc),
da*db - FX_S1615_INT_TO_DOUBLE(fc));
fc =FX_1615_LONGLONG_MUL1(fa,fb); fc =FX_1615_LONGLONG_MUL1(fa,fb);
printf("Exact answer = %f func result = %f, error = %f\n",da*db, FX_S1615_INT_TO_DOUBLE(fc), printf("Exact answer = %f func result = %f, error = %f\n",da*db, FX_S1615_INT_TO_DOUBLE(fc),
da*db - FX_S1615_INT_TO_DOUBLE(fc)); da*db - FX_S1615_INT_TO_DOUBLE(fc));
...@@ -208,8 +138,21 @@ int main(void) { ...@@ -208,8 +138,21 @@ int main(void) {
fc =FX_1615_LONGLONG_MUL3(fa,fb); fc =FX_1615_LONGLONG_MUL3(fa,fb);
printf("Exact answer = %f func result = %f, error = %f\n",da*db, FX_S1615_INT_TO_DOUBLE(fc), printf("Exact answer = %f func result = %f, error = %f\n",da*db, FX_S1615_INT_TO_DOUBLE(fc),
da*db - FX_S1615_INT_TO_DOUBLE(fc)); da*db - FX_S1615_INT_TO_DOUBLE(fc));
#endif
#ifdef FX_DIV_TEST
double da;
double db;
scanf("%lf %lf",&da, &db);
fx_s1615 fa,fb,fc;
fa =FX_S1615_DOUBLE_TO_INT(da);
fb =FX_S1615_DOUBLE_TO_INT(db);
printf("\nTest division\n"); printf("\nTest division\n");
fc =FX_S1615_DIV(fa,fb);
printf("Exact answer = %f func result = %f, error = %f\n",da/db, FX_S1615_INT_TO_DOUBLE(fc),
da/db - FX_S1615_INT_TO_DOUBLE(fc));
fc =FX_1615_LONGLONG_DIV01(fa,fb); fc =FX_1615_LONGLONG_DIV01(fa,fb);
printf("Exact answer = %f func result = %f, error = %f\n",da/db, FX_S1615_INT_TO_DOUBLE(fc), printf("Exact answer = %f func result = %f, error = %f\n",da/db, FX_S1615_INT_TO_DOUBLE(fc),
da/db - FX_S1615_INT_TO_DOUBLE(fc)); da/db - FX_S1615_INT_TO_DOUBLE(fc));
...@@ -221,44 +164,8 @@ int main(void) { ...@@ -221,44 +164,8 @@ int main(void) {
fc =FX_1615_LONGLONG_DIV03(fa,fb); fc =FX_1615_LONGLONG_DIV03(fa,fb);
printf("Exact answer = %f func result = %f, error = %f\n",da/db, FX_S1615_INT_TO_DOUBLE(fc), printf("Exact answer = %f func result = %f, error = %f\n",da/db, FX_S1615_INT_TO_DOUBLE(fc),
da/db - FX_S1615_INT_TO_DOUBLE(fc)); da/db - FX_S1615_INT_TO_DOUBLE(fc));
/*
clock_t start = clock();
volatile long long sum = 0;
for(int i = 0 ; i < INT_MAX ; i++) {
double a = 20.0, b = 30.0;
fx_s1615 fxa = FX_S1615_DOUBLE_TO_INT(a), fxb = FX_S1615_DOUBLE_TO_INT(b);
#ifndef TEST
printf("%f %d %f %d\n", a, fxa, b, fxb);
#endif
fx_s1615 fxc = FX_S1615_DIV(fxa, fxb);
#ifndef TEST
printf("%d %f\n", fxc, FX_S1615_INT_TO_DOUBLE(fxc));
#endif
double d = 50.0;
fx_s1615 fxd = FX_S1615_DOUBLE_TO_INT(d);
#ifndef TEST
printf("%f %f\n", FX_S1615_INT_TO_DOUBLE(fxd), FX_S1615_INT_TO_DOUBLE(sqrt_fx_s1615_int(fxd)));
#endif #endif
double e = 3.0;
fx_s1615 fxe = FX_S1615_DOUBLE_TO_INT(e);
#ifndef TEST
printf("%f %f\n", FX_S1615_INT_TO_DOUBLE(fxe), FX_S1615_INT_TO_DOUBLE(power_fx_s1615_int(fxe, 4)));
#endif
double f = 30.0;
fx_s1615 fxf = FX_S1615_DOUBLE_TO_INT(f);
#ifndef TEST
printf("%f %f\n", FX_S1615_INT_TO_DOUBLE(fxf), FX_S1615_INT_TO_DOUBLE(sine_fx_s1615_int(fxf)));
#endif
sum = fxa + fxb + fxc + fxd + fxe + fxf;
}
clock_t end = clock();
printf("Dummy sum: %lld\n", sum);
printf("Total run time: %lf\n", (double)(end - start) / CLOCKS_PER_SEC);
*/
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment