1: /* 2: function: gauss-weights 3: */ 4: #include <stdio.h> 5: 6: void gauss_weights(width,weight) 7: int width; 8: float *weight; 9: { 10: double exp (), foldwidth, halfwidth, power, sum = 0.0; 11: int ia; 12: 13: foldwidth = ((double) width - 1.0) / 3.0; 14: halfwidth = ((double) width - 1.0) / 2.0; 15: 16: /* compute unscaled weights */ 17: for (ia = 1; ia <= width; ia++) 18: { 19: power = (halfwidth - (double) ia + 1.0) / foldwidth; 20: power = -1.0 * power * power; 21: weight[ia] = exp (power); 22: sum += weight[ia]; 23: 24: /* set pointers */ 25: } 26: 27: /* scale weights to add to 1.0 */ 28: for (ia = 1; ia <= width; ia++) 29: weight[ia] /= sum; 30: 31: } /* end gauss_weights */ 32: