Fast Fourier transform: Difference between revisions
Content added Content deleted
Line 1,473: | Line 1,473: | ||
=={{header|lambdatalk}}== |
=={{header|lambdatalk}}== |
||
<lang scheme> |
<lang scheme> |
||
From a code written by Prasenjit Saha in https://www.physik.uzh.ch/~psaha/mus/fourlisp.php]] we build the FFT using lists. |
|||
1) the function fft |
1) the function fft |
||
{def fft |
{def fft |
||
{lambda {:s : |
{lambda {:s :x} |
||
{if {= {list.length : |
{if {= {list.length :x} 1} |
||
then : |
then :x |
||
else { |
else {let { {:s :s} |
||
{:ev {fft :s {evens :x}} } |
|||
⚫ | |||
⚫ | |||
{def combine |
|||
{list.append {list.map Cadd :ev :t} |
|||
{list.map Csub :ev :t}} }}}}} |
|||
{def plusminus |
|||
{lambda {:a :b} |
|||
{list.append {list.map Cadd :a :b} |
|||
⚫ | |||
{def rotate |
{def rotate |
||
{lambda {:s : |
{lambda {:s :f :k :N} |
||
{if {list.null? :f} |
{if {list.null? :f} |
||
then nil |
then nil |
||
else {cons {Cmul {car :f} |
else {cons {Cmul {car :f} {Cexp {Cnew 0 {/ {* :s {PI} :k} :N}}}} |
||
{rotate :s {cdr :f} {+ :k 1} :N}}}}} |
|||
⚫ | |||
2) functions for lists |
2) functions for lists |