changeset 314:395bb475b4cc

... while this tail recursive revision doesn't work: it loses all but the head of the remaining list when recursing
author Chris Cannam
date Sun, 02 Jun 2013 20:32:16 +0100
parents 5163b2cf6bcd
children ad1ec5932693
files yetilab/stream/filter.yeti
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/yetilab/stream/filter.yeti	Sun Jun 02 20:28:12 2013 +0100
+++ b/yetilab/stream/filter.yeti	Sun Jun 02 20:32:16 2013 +0100
@@ -286,8 +286,8 @@
     println "\(end-start)ms";
     result);
 
-fastConvolve irframes history remaining /*acc*/ = 
-   (println "convolve: irframes \(length irframes) history \(length history) remaining \(length remaining)";
+fastConvolve irframes history remaining acc = 
+   (println "convolve: irframes \(length irframes) history \(length history) remaining \(length remaining) acc \(length acc)";
     case remaining of
     first::rest:
        (println "convolve: \(length remaining) remaining of which length rest is \(length rest)";
@@ -299,10 +299,9 @@
                     map2 cplx.multiply irf histf;
                     done irframes newhistory));
         println "convolve: recursing with \(length rest) frames";
-//        fastConvolve irframes newhistory rest (acc ++ [convolvedFrame]));
-        convolvedFrame :: fastConvolve irframes newhistory rest);
+        fastConvolve irframes newhistory rest (acc ++ [convolvedFrame]));
      _: println "remaining only has 0 or 1 entries, returning";
-        [];
+        acc;
     esac);
 
 fastConvolvedWith ir framesize s =
@@ -315,7 +314,7 @@
 println "sigfr has \(len) frames";
     fs1 = framesize + 1;
     cframes = fastConvolve
-        irfr [] (sigfr ++ (map \(cplx.zeros fs1) [1..length irfr-1])) /* [] */;
+        irfr [] (sigfr ++ (map \(cplx.zeros fs1) [1..length irfr-1])) [];
     rframes = (vec.zeros (framesize * 2)) ::
         map (fft.realInverse (framesize * 2)) cframes;
 //    println "irfr \(irfr)\nsigfr \(sigfr)\ncframes \(cframes)\nrframes \(rframes)\nframesize \(framesize)";