Skip to content

Instantly share code, notes, and snippets.

@axman6
Created January 29, 2011 14:46
Show Gist options
  • Save axman6/801883 to your computer and use it in GitHub Desktop.
Save axman6/801883 to your computer and use it in GitHub Desktop.
fft :: [[Integer]] -> [Integer] -> Integer -> Integer -> Integer -> Integer
fft as rho m mM sig pc = ... cooleyTukey bs (rhoMult m mM) (mM `div` mM) ...
where Ibs = zipWith (badMult m mM sig pc) pr as
pr = powersOfRho (m * 2) rho m mM sig pc
data Constants = C { mM :: Integer, sig :: Integer, pc :: Integer}
fft :: [[Integer]] -> [Integer] -> Integer -> Integer -> Integer -> Integer
fft as rho m mM sig pc = runReader fft' (Constants mM sig pc)
fft' = do
pr <- powersOfRho
uibd <- zipWithM badMult pr as
return (cooleyTukey ...)
badMult :: Reader Integer
badMult = do
m' <- asks m
<ask for any more values you need to return>
...
let x = <result of computation that used to be badMult>
return x
powersOfRho :: Reader [Integer]
powersOfRho = do
m' <- asks m
rho' <- asks rho
...
let x = <computation that used to be in powersOfRho>
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment