[Kst] extragear/graphics/kst/src/libkstmath

Andrew Walker arwalker at sumusltd.com
Thu May 25 18:51:20 CEST 2006


SVN commit 544645 by arwalker:

BUG:124158 Normalize not just the default window, but all the others as well.

 M  +31 -0     kstpsd.cpp  


--- trunk/extragear/graphics/kst/src/libkstmath/kstpsd.cpp #544644:544645
@@ -236,28 +236,44 @@
       for (i = 0; i < len; i++) {
         x = i-a;
         w[i] = (1.0 - fabs(x)/a);
+        sW += w[i] * w[i];
       }
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // Blackman function 
     case 2:
       for (i = 0; i < len; i++) {
         x = i-a;
         w[i] = 0.42 + 0.5*cos(M_PI*x/a) + 0.08*cos(2*M_PI*x/a);
+        sW += w[i] * w[i];
       }
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // Connes function
     case 3: 
       for (i = 0; i < len; i++) {
         x = i-a;
         w[i] = pow(1.0-(x*x)/(a*a), 2.0);
+        sW += w[i] * w[i];
       }
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // cosine function
     case 4:
       for (i = 0; i < len; i++) {
         x = i-a;
         w[i] = cos((M_PI*x)/(2.0*a));
+        sW += w[i] * w[i];
       }
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // Gaussian function
     case 5:
@@ -265,27 +281,42 @@
         x = i-a;
         w[i] = exp((-1.0*x*x)/(2.0*gaussianSigma*gaussianSigma));
       }
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // Hamming function
     case 6:
       for (i = 0; i < len; i++) {
         x = i-a;
         w[i] = 0.53836 + 0.46164*cos(M_PI*x/a);
+        sW += w[i] * w[i];
       }  
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // Hann function
     case 7:
       for (i = 0; i < len; i++) {
         x = i-a;
         w[i] = pow(cos((M_PI*x)/(2.0*a)), 2.0);
+        sW += w[i] * w[i];
       }
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // Welch function
     case 8:
       for (i = 0; i < len; i++) {
         x = i-a;
         w[i] = 1.0 - (x*x)/(a*a);
+        sW += w[i] * w[i];
       }
+      for (i = 0; i < len; i++) {
+        w[i] /= sW;
+      }
       break;
     // uniform/rectangular function
     default:


More information about the Kst mailing list