-
-
Notifications
You must be signed in to change notification settings - Fork 359
Cooley-Tukey in Scala #746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only looked at the first implementation so far.
def cooleyTukey(signal: IndexedSeq[Double]): IndexedSeq[Complex] = signal.length match { | ||
case 2 => mergeTransforms( | ||
Vector(new Complex(signal(0), 0)), | ||
Vector(new Complex(signal(1), 0))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the last parenthesis be on a separate line for this code style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find anything in the style guide on that topic, but all the examples put the closing paren on the same line, so I did it as well.
val oddTerms = for (i <- odds.indices) | ||
yield coefficient(1, i, 2 * odds.length) * odds(i) | ||
|
||
val pairs = evens.zip(oddTerms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't you need to calculate even terms too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because only the odd values are multiplied with the coefficients. The 'evenTerms' would just be the 'evens' parameter.
[lang: scala] |
FFT implementation in Scala.
The code (hopefully) follows this style guide: https://docs.scala-lang.org/style/index.html
A runnable version of the code is on Repl.it: https://repl.it/@Delphi1024/FFT-Algorithm-Archive#main.scala
~Delphi1024