Permalink
Browse files

Randomizer implemented. Need to start testing FFT with convolution.

  • Loading branch information...
1 parent 5f5e5be commit 0a82d80a0ae77a9039d7bb55f8bcf14e19e73876 Grant Rotskoff committed May 30, 2012
Showing with 19 additions and 2 deletions.
  1. +10 −2 Functions.hs
  2. +9 −0 fft.hs
View
@@ -4,6 +4,7 @@ module Functions where
import Sn
import Group
import Data.Complex
+import Data.List (unfoldr)
import System.Random
import qualified Data.Map as Map
@@ -31,8 +32,15 @@ add (F f) (F g)
| otherwise = F $ Map.fromList $ zip (k f) vs where
vs = zipWith (+) (v f) (v g)
-randomF :: Int -> SnMap
-randomF n = undefined
+randomls :: Int -> StdGen -> [Double]
+randomls n = take n . unfoldr (Just . randomR (0,1))
+
+randomF :: Int -> IO SnMap
+randomF n = do
+ seed <- newStdGen
+ let ks = s n
+ let vs = randomls (length ks) seed
+ return $ F $ Map.fromList $ zip ks vs
-- A key step to the recursion of the Fourier Transform is the adaptation of
-- SnMaps to the subgroups of Sn. Essentially, this is a precise way of
View
9 fft.hs
@@ -30,6 +30,15 @@ fft (F f) l
n = factInv $ fDim (F f)
+randomFFT :: Partition -> (IO [[Double]])
+randomFFT (Part l) = (randomF n) >>= (\s -> return (fft s (Part l))) where
+ n = sum l
+
+
+
+
+
+-- Temp. / Inelegant
factInv :: Int -> Int
factInv x = case x of
1 -> 1

0 comments on commit 0a82d80

Please sign in to comment.