arb-fft 0.2.0.2 → 0.3.0.0
raw patch · 9 files changed
+54/−67 lines, 9 filesdep ~QuickCheckdep ~criteriondep ~filepathsetup-changed
Dependency ranges changed: QuickCheck, criterion, filepath, primitive, transformers, vector
Files
- CHANGELOG.markdown +4/−0
- Numeric/FFT.hs +2/−2
- Numeric/FFT/Plan.hs +16/−28
- Setup.hs +13/−21
- arb-fft.cabal +10/−10
- doc-formulae/fft-formula.svg +1/−1
- doc-formulae/ifft-formula.svg +1/−1
- test/basic-test.hs +2/−2
- test/profile-256.hs +5/−2
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+0.3.0.0+-------+* Updates for ghcjs and new Criterion.+ 0.2.0.2 ------- * Fix documentation image links.
Numeric/FFT.hs view
@@ -25,7 +25,7 @@ -- calculates the entries in /H/, the discrete Fourier transform of -- /h/, as: ----- <<http://www.skybluetrades.net/images/arb-fft/fft-formula.svg>>+-- <<doc-formulae/fft-formula.svg>> fft :: Vector v (Complex Double) => v (Complex Double) -> IO (v (Complex Double)) fft xs = do@@ -37,7 +37,7 @@ -- representing Fourier amplitudes of a signal, calculates the entries -- in /h/, the inverse discrete Fourier transform of /H/, as: ----- <<http://www.skybluetrades.net/images/arb-fft/ifft-formula.svg>>+-- <<doc-formulae/ifft-formula.svg>> ifft :: Vector v (Complex Double) => v (Complex Double) -> IO (v (Complex Double)) ifft xs = do
Numeric/FFT/Plan.hs view
@@ -2,6 +2,7 @@ import Prelude hiding ((++), any, concatMap, enumFromTo, filter, length, map, maximum, null, reverse, scanl, sum, zip, zipWith)+import qualified Prelude import qualified Prelude as P import Control.Applicative ((<$>)) import qualified Control.Monad as CM@@ -20,11 +21,9 @@ import System.Environment import System.FilePath import System.IO-import System.IO.Unsafe (unsafePerformIO)-import Criterion-import Criterion.Config-import Criterion.Monad-import Criterion.Environment+import Criterion.Measurement (measure)+import Criterion.Main.Options+import Criterion.Types hiding (measure) import Numeric.FFT.Types import Numeric.FFT.Execute@@ -36,11 +35,6 @@ nTestPlans :: Int nTestPlans = 50 --- | Globally shared timing environment. (Not thread-safe...)-timingEnv :: IORef (Maybe Environment)-timingEnv = unsafePerformIO (newIORef Nothing)-{-# NOINLINE timingEnv #-}- -- | Plan calculation for a given problem size. plan :: Int -> IO Plan plan 1 = return $ Plan V.empty Nothing (SpecialBase 1)@@ -52,26 +46,20 @@ return $ p { plBase = bpl { raderConvPlan = cplan } } _ -> return p pret <- case wis of- Just (p, t) -> planFromFactors n p+ Just (p, _) -> planFromFactors n p Nothing -> do let ps = testPlans n nTestPlans- withConfig (defaultConfig { cfgVerbosity = ljust Quiet- , cfgSamples = ljust 1 }) $ do- menv <- liftIO $ readIORef timingEnv- env <- case menv of- Just e -> return e- Nothing -> do- meas <- measureEnvironment- liftIO $ writeIORef timingEnv $ Just meas- return meas- let v = generate n (\i -> sin (2 * pi * fromIntegral i / 511) :+ 0)- tps <- CM.forM ps $ \p -> do- ptest <- liftIO $ planFromFactors n p >>= fixRader- ts <- runBenchmark env $ nf (execute ptest Forward) v- return (sum ts / fromIntegral (length ts), p)- let (rest, resp) = L.minimumBy (compare `on` fst) tps- liftIO $ writeWisdom n resp rest- liftIO $ planFromFactors n resp+ v = generate n (\i -> sin (2 * pi * fromIntegral i / 511) :+ 0)+ tps <- CM.forM ps $ \p -> do+ ptest <- liftIO $ planFromFactors n p >>= fixRader+ let niters = fromIntegral $ 50000 `div` n+ (meas, _) <- measure (nf (execute ptest Forward) v) niters+ let t = measTime meas / fromIntegral (measIters meas)+ iters = measIters meas+ return (t, p)+ let (rest, resp) = L.minimumBy (compare `on` fst) tps+ liftIO $ writeWisdom n resp rest+ liftIO $ planFromFactors n resp fixRader pret -- | Get execution time for plan for a given problem size.
Setup.hs view
@@ -1,33 +1,25 @@-import Control.Applicative ((<$>)) import Control.Monad (when)-import Data.List (delete)-import Data.Maybe (isJust) import Distribution.PackageDescription import Distribution.Simple import Distribution.Simple.Configure import Distribution.Simple.LocalBuildInfo-import Distribution.Simple.Program import Distribution.Simple.Setup-import Distribution.Verbosity checkLLVM :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo-checkLLVM (pkg, hbi) inflags = do- installed <- isJust <$> findProgramLocation verbose "llvm-config"- let llvmf = FlagName "llvm"- cfgflags = configConfigurationsFlags inflags- fixcfgflags = (llvmf, False) : delete (llvmf, True) cfgflags- fixflags = inflags { configConfigurationsFlags = fixcfgflags }- let (flags, msg) = case installed of- True -> (inflags, False)- False -> case lookup llvmf cfgflags of- Just True -> (fixflags, True)- Just False -> (inflags, False)- Nothing -> (fixflags, True)- when msg $ do- putStrLn "Warning: LLVM is not installed."- putStrLn "Building arb-fft with native code generator (slower)."- configure (pkg, hbi) flags+checkLLVM (pkg, hbi) flgs = do+ let warn = case lookup (FlagName "llvm") $ configConfigurationsFlags flgs of+ Nothing -> True+ Just True -> False+ Just False -> True+ when warn $ do+ putStrLn "============================================================"+ putStrLn " WARNING: LLVM flag is not set."+ putStrLn ""+ putStrLn " Building arb-fft with native code generator (slower)."+ putStrLn " Reconfigure with -fllvm to build with LLVM."+ putStrLn "============================================================"+ configure (pkg, hbi) flgs main :: IO () main = defaultMainWithHooks simpleUserHooks { confHook = checkLLVM }
arb-fft.cabal view
@@ -1,5 +1,5 @@ name: arb-fft-version: 0.2.0.2+version: 0.3.0.0 synopsis: Pure Haskell arbitrary length FFT library homepage: https://github.com/ian-ross/arb-fft license: BSD3@@ -31,7 +31,7 @@ location: https://github.com/ian-ross/arb-fft Flag LLVM- default: True+ default: False description: Use LLVM build for better performance Library@@ -47,12 +47,12 @@ ghc-prof-options: -auto-all -caf-all build-depends: base >= 4.6 && < 5, containers >= 0.5.0.0 && < 0.6,- criterion >= 0.8.0.0 && < 0.9,+ criterion >= 1.1 && < 1.2, directory >= 1.2.0.1 && < 1.3,- filepath >= 1.3.0.1 && < 1.4,- primitive >= 0.5.1.0 && < 0.6,- transformers >= 0.3.0.0 && < 0.4,- vector >= 0.10.9.1 && < 0.11+ filepath >= 1.3.0.1 && < 1.5,+ primitive >= 0.5.1.0 && < 0.7,+ transformers >= 0.3.0.0 && < 0.5,+ vector >= 0.10.9.1 && < 0.12 default-language: Haskell2010 if flag(LLVM) ghc-options: -O2 -fllvm@@ -66,8 +66,8 @@ build-depends: arb-fft, base >= 4.6 && < 5, containers >= 0.5.0.0 && < 0.6,- vector >= 0.10.9.1 && < 0.11,- QuickCheck >= 2.6 && < 2.7,+ vector >= 0.10.9.1 && < 0.12,+ QuickCheck >= 2.8 && < 2.9, tasty >= 0.3, tasty-quickcheck >= 0.3 default-language: Haskell2010@@ -78,6 +78,6 @@ build-depends: arb-fft, base >= 4.6 && < 5, containers >= 0.5.0.0 && < 0.6,- vector >= 0.10.9.1 && < 0.11,+ vector >= 0.10.9.1 && < 0.12, criterion default-language: Haskell2010
doc-formulae/fft-formula.svg view
@@ -1,7 +1,7 @@ <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <!-- This file was generated by dvisvgm 1.2.2 (x86_64-unknown-linux-gnu) -->-<!-- Fri Jan 31 12:50:53 2014 -->+<!-- Fri Feb 21 15:44:57 2014 --> <svg height='29.2017pt' version='1.1' viewBox='135.099 64.7572 197.049 29.2017' width='197.049pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'> <defs> <path d='M1.92 -0.53C1.92 -0.82 1.68 -1.06 1.39 -1.06S0.86 -0.82 0.86 -0.53S1.1 0 1.39 0S1.92 -0.24 1.92 -0.53Z' id='g0-58'/>
doc-formulae/ifft-formula.svg view
@@ -1,7 +1,7 @@ <?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <!-- This file was generated by dvisvgm 1.2.2 (x86_64-unknown-linux-gnu) -->-<!-- Fri Jan 31 12:50:54 2014 -->+<!-- Fri Feb 21 15:44:57 2014 --> <svg height='28.853pt' version='1.1' viewBox='125.415 64.7572 216.418 28.853' width='216.418pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'> <defs> <path d='M1.92 -0.53C1.92 -0.82 1.68 -1.06 1.39 -1.06S0.86 -0.82 0.86 -0.53S1.1 0 1.39 0S1.92 -0.24 1.92 -0.53Z' id='g0-58'/>
test/basic-test.hs view
@@ -4,8 +4,8 @@ import Prelude hiding ((++), length, map, maximum, sum, zipWith) import qualified Prelude as P import Test.Tasty-import Test.Tasty.QuickCheck-import Test.QuickCheck+import Test.Tasty.QuickCheck hiding (generate)+import Test.QuickCheck hiding (generate) import Test.QuickCheck.Monadic import Control.Applicative ((<$>)) import Data.Complex
test/profile-256.hs view
@@ -1,6 +1,8 @@ module Main where -import Criterion.Main+import Criterion+import Criterion.Main.Options+import Criterion.Types import Data.Complex import Data.Vector import qualified Numeric.FFT as FFT@@ -12,4 +14,5 @@ main :: IO () main = do p <- FFT.plan 256- run (nf (FFT.fftWith p) (tstvec 256)) 1000+ benchmarkWith (defaultConfig { resamples = 1000 }) + (nf (FFT.fftWith p) (tstvec 256))