Saturday, November 8, 2008

Sinc function

Today we're going to a Sinc function, both normalized and unnormalized. Apparently it's useful in digital signal processing.


ASP

  1. Const M_PI = 3.14159265358979323846
  2. ' Unnormalized sinc function.
  3. function sinc(x)
  4.     sinc = sin(x) / x
  5. end function
  6. ' Normalized sinc function.
  7. ' REQUIRES: constant M_PI
  8. function nsinc(x)
  9.     sinc = sin(M_PI * x) / (M_PI * x)
  10. end function

PHP

  1. // Unnormalized sinc function.
  2. function sinc($x)
  3. {
  4.     return sin($x) / $x;
  5. }
  6. // Normalized sinc function.
  7. function nsinc($x)
  8. {
  9.     return sin(M_PI * $x) / (M_PI * $x);
  10. }

No comments: