solution for asin trouble from report
This commit is contained in:
16
stdlib.ispc
16
stdlib.ispc
@@ -3810,22 +3810,14 @@ static inline double sin(double x) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
__declspec(safe)
|
__declspec(safe)
|
||||||
static inline double asin(double x) {
|
static inline uniform double asin(uniform double x) {
|
||||||
if (__have_native_trigonometry)
|
if (__have_native_trigonometry)
|
||||||
{
|
{
|
||||||
return __asin_varying_double(x);
|
return __asin_uniform_double(x);
|
||||||
}
|
}
|
||||||
else if (__math_lib == __math_lib_svml)
|
else
|
||||||
{
|
{
|
||||||
return __svml_asind(x);
|
return __stdlib_asin(x);
|
||||||
}
|
|
||||||
else {
|
|
||||||
double ret;
|
|
||||||
foreach_active (i) {
|
|
||||||
uniform double r = __stdlib_asin(extract(x, i));
|
|
||||||
ret = insert(ret, i, r);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,47 @@ export uniform int width() { return programCount; }
|
|||||||
|
|
||||||
|
|
||||||
bool ok(float x, float ref) { return (abs(x - ref) < 1e-6) || abs((x-ref)/ref) < 1e-6; }
|
bool ok(float x, float ref) { return (abs(x - ref) < 1e-6) || abs((x-ref)/ref) < 1e-6; }
|
||||||
|
bool ok(double x, double ref) { return (abs(x - ref) < 1e-6) || abs((x-ref)/ref) < 1e-6; }
|
||||||
|
|
||||||
export void f_v(uniform float RET[]) {
|
export void f_v(uniform float RET[]) {
|
||||||
uniform float vals[8] = { 0, 1, 0.5, -1, -.87, -.25, 1e-3, -.99999999 };
|
uniform float vals_f[8] = { 0, 1, 0.5, -1, -.87, -.25, 1e-3, -.99999999 };
|
||||||
uniform float r[8];
|
uniform float r_f[8];
|
||||||
foreach (i = 0 ... 8)
|
foreach (i = 0 ... 8) //testing varying float
|
||||||
r[i] = sin(asin(vals[i%8]));
|
r_f[i] = sin(asin(vals_f[i%8]));
|
||||||
|
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
for (uniform int i = 0; i < 8; ++i) {
|
for (uniform int i = 0; i < 8; ++i) {
|
||||||
if (ok(r[i], vals[i%8]) == false) {
|
if (ok(r_f[i], vals_f[i%8]) == false) {
|
||||||
print("error @ %: got %, expected %\n", i, r[i], vals[i%8]);
|
print("error @ %: got %, expected %\n", i, r_f[i], vals_f[i%8]);
|
||||||
|
++errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (uniform int i = 0; i < 8 ; i++){
|
||||||
|
r_f[i] = sin(asin(vals_f[i%8])); //testing uniform float
|
||||||
|
}
|
||||||
|
for (uniform int i = 0; i < 8; ++i) {
|
||||||
|
if (ok(r_f[i], vals_f[i%8]) == false) {
|
||||||
|
print("error @ %: got %, expected %\n", i, r_f[i], vals_f[i%8]);
|
||||||
|
++errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uniform double vals_d[8] = { 0, 1, 0.5, -1, -.87, -.25, 1e-3, -.99999999 };
|
||||||
|
uniform double r_d[8];
|
||||||
|
foreach (i = 0 ... 8)
|
||||||
|
r_d[i] = sin(asin(vals_d[i%8])); //testing varying double
|
||||||
|
|
||||||
|
for (uniform int i = 0; i < 8; ++i) {
|
||||||
|
if (ok(r_d[i], vals_d[i%8]) == false) {
|
||||||
|
print("error @ %: got %, expected %\n", i, r_d[i], vals_d[i%8]);
|
||||||
|
++errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (uniform int i = 0; i < 8 ; i++){
|
||||||
|
r_d[i] = sin(asin(vals_d[i%8])); //testing uniform double
|
||||||
|
}
|
||||||
|
for (uniform int i = 0; i < 8; ++i) {
|
||||||
|
if (ok(r_d[i], vals_d[i%8]) == false) {
|
||||||
|
print("error @ %: got %, expected %\n", i, r_d[i], vals_d[i%8]);
|
||||||
++errors;
|
++errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user