gennorm.c 552 B

1234567891011121314151617181920212223242526
  1. /* gennorm.c */
  2. #include <math.h>
  3. #include <grass/gis.h>
  4. #include "ransurf.h"
  5. void GenNorm(void)
  6. {
  7. double t, b, c, sqr;
  8. int i;
  9. G_debug(2, "GenNorm()");
  10. Norm = (double *)G_malloc(SIZE_OF_DISTRIBUTION * sizeof(double));
  11. sqr = 1 / sqrt(2 * PI);
  12. c = 0.0;
  13. for (i = 0; i < SIZE_OF_DISTRIBUTION; i++) {
  14. t = ((double)(i - SIZE_OF_DISTRIBUTION / 2)) * DELTA_T;
  15. b = exp(-t * t / 2.0) * sqr * DELTA_T;
  16. c = c + b;
  17. G_debug(3, "(c):%.12lf", c);
  18. Norm[i] = c;
  19. }
  20. return;
  21. }