[Scipy-svn] r5485 - trunk/scipy/fftpack/src

scipy-svn@scip... scipy-svn@scip...
Sun Jan 18 05:25:24 CST 2009


Author: cdavid
Date: 2009-01-18 05:25:15 -0600 (Sun, 18 Jan 2009)
New Revision: 5485

Modified:
   trunk/scipy/fftpack/src/dct.c.src
Log:
Support normalization for dct type III.

Modified: trunk/scipy/fftpack/src/dct.c.src
===================================================================
--- trunk/scipy/fftpack/src/dct.c.src	2009-01-18 11:24:57 UTC (rev 5484)
+++ trunk/scipy/fftpack/src/dct.c.src	2009-01-18 11:25:15 UTC (rev 5485)
@@ -113,24 +113,37 @@
 
 void @pref@dct3(@type@ * inout, int n, int howmany, int normalize)
 {
-    int i;
+    int i, j;
     @type@ *ptr = inout;
     @type@ *wsave = NULL;
+    @type@ n1, n2;
 
     wsave = caches_@pref@dct2[get_cache_id_@pref@dct2(n)].wsave;
 
-    for (i = 0; i < howmany; ++i, ptr += n) {
-        @pref@cosqf_(&n, ptr, wsave);
-
-    }
-
     switch (normalize) {
         case DCT_NORMALIZE_NO:
             break;
+        case DCT_NORMALIZE_ORTHONORMAL:
+            n1 = sqrt(1./n);
+            n2 = sqrt(0.5/n);
+            for (i = 0; i < howmany; ++i, ptr+=n) {
+                ptr[0] *= n1;
+                for (j = 1; j < n; ++j) {
+                    ptr[j] *= n2;
+                }
+            }
+            break;
         default:
             fprintf(stderr, "dct3: normalize not yet supported=%d\n",
                     normalize);
             break;
     }
+
+    ptr = inout;
+    for (i = 0; i < howmany; ++i, ptr += n) {
+        @pref@cosqf_(&n, ptr, wsave);
+
+    }
+
 }
 /**end repeat**/



More information about the Scipy-svn mailing list