added fast approximate rcp(double) accurate to 15 digits

This commit is contained in:
Evghenii
2014-02-04 15:23:34 +01:00
parent eb1a495a7a
commit fe98fe8cdc
3 changed files with 34 additions and 15 deletions

View File

@@ -3,12 +3,12 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
double x = aFOO[programIndex&0x3];
double x = aFOO[programIndex&0x3]*1d100;
double d, ix;
ix = rcp(x);
d = (ix - 1.0d0 / x);
d = (d < 0.0d0) ? -d : d;
RET[programIndex] = (d < 1d-7) ? 1.0d0 : 0.0d0;
RET[programIndex] = (d < 1d-15 && !isnan(d)) ? 1.0d0 : 0.0d0;
}
export void result(uniform float RET[]) {