35 #define MAX_TEST_COUNT 110465 37 #define TEST_COUNT MAX_TEST_COUNT 39 #if TEST_COUNT > MAX_TEST_COUNT 40 #error TEST_COUNT is above maximum 47 int main(
int argc,
char** argv)
49 printf(
"argc: %d\n", argc);
50 coord_t inp_x, inp_y, out_x, out_y;
51 phase_t inp_rad, out_rad;
54 float diff, total_error = 0;
61 fp = fopen(
"./vector.dat",
"w");
63 fprintf(
stderr,
"unable to open output file\n");
65 fm = fopen(
"./check_res.m",
"w");
67 fprintf(
stderr,
"unable to open MATLAB ile\n");
69 fprintf(fm,
"clear all; close all; clc;\n");
70 fprintf(fm,
"%%%%\n");
71 fprintf(fm,
"dat = load('vector.dat');\n");
72 fprintf(fm,
"diff = abs(dat(:,3) - dat(:,4));\n");
73 fprintf(fm,
"diff2= abs(dat(:,4) - dat(:,5));\n");
74 fprintf(fm,
"figure; plot(diff); title 'error CORDIC vs. ATAN2'; grid;\n");
75 fprintf(fm,
"figure; plot(diff2); title 'error2'; grid;\n");
76 fprintf(fm,
"max_diff = max(diff)\n");
77 fprintf(fm,
"sum_abs_err = sum(diff)\n");
78 fprintf(fm,
"max_diff2 = max(diff2)\n");
79 fprintf(fm,
"sum_abs_err2 = sum(diff2)\n");
82 read_file<TEST_COUNT, 2, coord_t>(
"./input_data.txt",
input_data);
83 read_file<TEST_COUNT, 1, phase_t>(
"./ref_results.txt",
ref_results);
96 float c_atan2 = atan2f((
float) inp_y, (
float) inp_x);
105 fprintf(fp,
"%20.10f %20.10f %20.10f %20.10f %20.10f\n",
106 (
float) inp_y, (
float) inp_x, (
float) out_rad,
107 (
float) ref_results[i][0], (
float) c_atan2);
112 fprintf(
stderr,
"total error = %f\n", total_error);
113 fprintf(
stderr,
"relative error = %f\n", total_error / TEST_COUNT);
int main(int argc, char **argv)
coord_t input_data[TEST_COUNT][2]
phase_t ref_results[TEST_COUNT][1]
void top_atan2(coord_t y0, coord_t x0, phase_t *zn)