Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

0xJonas
Copy link
Contributor

@0xJonas 0xJonas commented Aug 31, 2020

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

@berquist berquist added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Oct 3, 2020
Copy link
Contributor

@Vexatos Vexatos left a 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)))
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

@0xJonas 0xJonas Oct 3, 2020

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.

@ntindle
Copy link
Member

ntindle commented Aug 28, 2021

[lang: scala]

@github-actions github-actions bot added the lang: scala Scala programming language label Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) lang: scala Scala programming language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants