在我的测试代码中,复杂计算使用的cpu时间CX_LIMITED_RANGE ON/OFF
没有区别。之间有什么区别CX_LIMITED_RANGE ON/OFF
,我们何时以及如何使用#pragma STDC CX_LIMITED_RANGE ON
,以及何时使用 default #pragma STDC CX_LIMITED_RANGE OFF
。
谢谢!
void use_CX_LIMITED_RANGE()
{
double complex z1 = 3.0 + I * 4.0;
double complex z2 = 1.0 + I * 2.0;
#pragma STDC CX_LIMITED_RANGE ON
clock_t c1 = clock();
double complex z3;
for (int i = 0; i < 100000; ++i) {
z3 = cabs(z1 * z2);
}
clock_t c2 = clock();
printf("CX_LIMITED_RANGE ON %lu cpu clock\n", c2 - c1);
printf("|z1 * z2| = %f + %fi\n", creal(z3), cimag(z3));
printf("\n");
#pragma STDC CX_LIMITED_RANGE OFF
c1 = clock();
for (int i = 0; i < 100000; ++i) {
z3 = cabs(z1 * z2);
}
c2 = clock();
printf("CX_LIMITED_RANGE OFF %lu\n", c2 - c1);
printf("|z1 * z2| = %f + %fi\n", creal(z3), cimag(z3));
}