Use hmatrix to generate random input with Gaussian distribution.
This commit is contained in:
parent
9a1803ec71
commit
703e4b2531
14
LowPass.hs
14
LowPass.hs
|
|
@ -8,8 +8,10 @@ import Data.List as L
|
|||
import Data.Vector.Storable as V
|
||||
import Data.Vector.Storable.Mutable as MV
|
||||
import Numeric.LinearAlgebra as LA
|
||||
import Numeric.GSL.Fourier as LA
|
||||
|
||||
import Control.Applicative
|
||||
import Data.Complex
|
||||
import System.Random
|
||||
import System.Time
|
||||
import Text.Printf
|
||||
|
|
@ -49,13 +51,15 @@ convolve kernel input = V.generate osize $ \j -> rkernel <.> V.slice j ksize inp
|
|||
main :: IO ()
|
||||
main = do
|
||||
let isize = 2000000
|
||||
(input, inputTime) <- time $ V.fromListN isize . randoms <$> newStdGen
|
||||
seed <- randomIO
|
||||
(input, inputTime) <- time $ return $ LA.randomVector seed Gaussian isize
|
||||
(_, kernelTime) <- time $ return lowPassKernel
|
||||
(result, resultTime) <- time $ return $ convolve lowPassKernel input
|
||||
V.mapM_ (printf "%0.6f\n") $ V.slice 0 50 result
|
||||
printf "Input Time: %0.6f seconds\n" $ inputTime
|
||||
printf "Kernel Time: %0.6f seconds\n" $ kernelTime
|
||||
printf "Result Time: %0.6f seconds\n" $ resultTime
|
||||
V.mapM_ (printf "%10.6f\n") $ V.slice 0 50 result
|
||||
--V.mapM_ (printf "%10.6f\n") $ V.map magnitude $ LA.fft $ V.map (:+0) result
|
||||
printf "Input Time: %8.6f seconds\n" $ inputTime
|
||||
printf "Kernel Time: %8.6f seconds\n" $ kernelTime
|
||||
printf "Result Time: %8.6f seconds\n" $ resultTime
|
||||
|
||||
time :: IO a -> IO (a, Double)
|
||||
time f = do
|
||||
|
|
|
|||
Loading…
Reference in New Issue