Difference between revisions of "Thread:User talk:Rednaxela/FastTrig/Fast gaussian kernel function"
Jump to navigation
Jump to search
(New thread: Fast gaussian kernel function) |
(No difference)
|
Latest revision as of 23:54, 18 February 2012
Patched a gaussian kernel to work together with that fast exp.
private static final double SQRT_2_PI = Math.sqrt(2 * Math.PI);
private static final double EXP_LIMIT = 700;
private static final double GAUSSIAN_LIMIT = Math.sqrt(EXP_LIMIT * 2);
public static double gaussian(final double u) {
if (u > GAUSSIAN_LIMIT || u < -GAUSSIAN_LIMIT) {
return 0;
}
return exp(-(u * u) / 2) / SQRT_2_PI;
}
public static double exp(double val) {
final long tmp = (long) (1512775 * val + 1072632447);
return Double.longBitsToDouble(tmp << 32);
}