Skip to content

Commit ce0a725

Browse files
committed
Test: ztest: Tighten the tolerance for test_icomplex32_to_polar
The atan2() function in sofm_ipolar32_to_complex() helped to increase accuracy, so the tolerance for error could be decreased to about 0.001 degrees (2.0e-5 radians). Also the print format for achieved accuracy is improved for nicer appearance. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 230bc41 commit ce0a725

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/ztest/unit/math/basic/complex/test_complex_polar.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(test_complex_polar, LOG_LEVEL_INF);
1515

1616
#define COMPLEX_ABS_TOL 1.2e-8
1717
#define MAGNITUDE_ABS_TOL 7.1e-8
18-
#define ANGLE_ABS_TOL 4.4e-5
18+
#define ANGLE_ABS_TOL 2.0e-5
1919

2020
/**
2121
* @brief Test complex to polar conversion function
@@ -35,7 +35,7 @@ ZTEST(math_complex, test_icomplex32_to_polar)
3535
double magnitude, angle;
3636
double delta_mag, delta_ang;
3737
double magnitude_scale_q30 = 1.0 / 1073741824.0; /* 1.0 / 2^30 */
38-
double angle_scale_q29 = 1.0 / 536870912.0; /* 1.0 / 2^29 */
38+
double angle_scale_q29 = 1.0 / 536870912.0; /* 1.0 / 2^29 */
3939
double delta_mag_max = 0;
4040
double delta_ang_max = 0;
4141
int i;
@@ -118,11 +118,11 @@ ZTEST(math_complex, test_ipolar32_to_complex)
118118

119119
/* Re-run worst cases to print info */
120120
sofm_ipolar32_to_complex(&polar_real_max, &complex);
121-
printf("delta_real_max = %g at (%d, %d) -> (%d, %d)\n", delta_real_max,
121+
printf(" INFO - delta_real_max = %g at (%d, %d) -> (%d, %d)\n", delta_real_max,
122122
polar_real_max.magnitude, polar_real_max.angle, complex.real, complex.imag);
123123

124124
sofm_ipolar32_to_complex(&polar_imag_max, &complex);
125-
printf("delta_imag_max = %g at (%d, %d) -> (%d, %d)\n", delta_imag_max,
125+
printf(" INFO - delta_imag_max = %g at (%d, %d) -> (%d, %d)\n", delta_imag_max,
126126
polar_imag_max.magnitude, polar_imag_max.angle, complex.real, complex.imag);
127127
}
128128

0 commit comments

Comments
 (0)