fft 0.1.0.0 → 0.1.0.1
raw patch · 4 files changed
+7/−146 lines, 4 files
Files
- Math/FFT.hs +6/−1
- README +0/−25
- fft.cabal +1/−1
- tests/tests.hs +0/−119
Math/FFT.hs view
@@ -159,7 +159,12 @@ -- ** Multi-dimensional transforms with possibly different transforms in each dimension dftRRN, -- ** General transforms- dftRRG+ dftRRG,++ -- * Wisdom+ importWisdomString,+ importWisdomSystem,+ exportWisdomString, ) where import Math.FFT.Base
− README
@@ -1,25 +0,0 @@-This package provides bindings to the FFTW library.--You will need to install FFTW version 3, including development files before this-package. Consult your package manager or visit http://fftw.org to install FFTW.-In addition, the Haskell package carray is required.-- runhaskell Setup.lhs configure- runhaskell Setup.lhs build- runhaskell Setup.lhs haddock (optional)- runhaskell Setup.lhs install--Then run the tests:-- runhaskell tests/tests.hs--We use the CArray package for multi-dimensional arrays. It allocates pinned-memory on the GC'd heap, which is 16-byte aligned by default, allowing SIMD-instructions. If you get a CArray from a foreign source using-unsafeForeignPtrToCArray (an O(1) operation) then you must be sure that the-memory is aligned if you expect SIMD code to be used by FFTW.--A note regarding licensing: FFTW is generally distributed under the GPL,-although a different license can be purchased. Therefore, the fact that these-bindings are BSD licensed does not mean you can link against a GPL'd copy of-FFTW without complying with the GPL.
fft.cabal view
@@ -1,5 +1,5 @@ name: fft-version: 0.1.0.0+version: 0.1.0.1 synopsis: Bindings to the FFTW library. description: Bindings to the FFTW library.
− tests/tests.hs
@@ -1,119 +0,0 @@-{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}-import Test.QuickCheck-import Data.Array.CArray-import Data.Complex-import Math.FFT-import Foreign.Storable-import Text.Printf-import System.Environment (getArgs)-import System.IO-import System.Random--instance Arbitrary (Complex Double) where- arbitrary = do- r <- arbitrary- i <- arbitrary- return $ r :+ i- coarbitrary = error "no coarbitrary for Complex"--instance (IArray CArray e, Arbitrary e) => Arbitrary (CArray Int e) where- arbitrary = do- u <- choose (1,100)- es <- vector (u+1)- return $ listArray (0,u) es- coarbitrary = error "no coarbitrary for CArray"--instance (IArray CArray e, Arbitrary e) => Arbitrary (CArray (Int,Int) e) where- arbitrary = do- u0 <- choose (1,30)- u1 <- choose (1,30)- es <- vector ((u0 + 1) * (u1 + 1))- return $ listArray ((0,0),(u0,u1)) es- coarbitrary = error "no coarbitrary for CArray"--instance (IArray CArray e, Arbitrary e) => Arbitrary (CArray (Int,Int,Int) e) where- arbitrary = do- u0 <- choose (1,20)- u1 <- choose (1,20)- u2 <- choose (1,20)- es <- vector ((u0 + 1) * (u1 + 1) * (u2 + 1))- return $ listArray ((0,0,0),(u0,u1,u2)) es- coarbitrary = error "no coarbitrary for CArray"----- about :: (Ix i, FFTWFloat e) => CArray i e -> CArray i e -> Bool-about x y = small $ normSup (liftArray2 (-) x y) / (1 + normSup (liftArray2 (+) x y))- where small a = a < 1e-15--partAbout a b = about a (slice ba ba b)- where ba = bounds a--aboutIdem f x = f x `about` x--prop_dft = aboutIdem $ idft . dft-prop_dftRC a = aboutIdem ((if odd (shape a !! 0) then dftCRO else dftCR) . dftRC) a-prop_dftRC_dft a = partAbout (dftRC a) (dft . amap (:+0) $ a)-prop_dht_idem a = aboutIdem (amap (/ fromIntegral (shape a !! 0)) . dht . dht) a---prop_dft2 = aboutIdem $ idft . dft-prop_dft22 = aboutIdem $ idftN [0,1] . dftN [0,1]-prop_dft22' = aboutIdem $ idftN [1,0] . dftN [1,0]--prop_dftRC2 a = aboutIdem ((if odd (shape a !! 0) then dftCRO else dftCR) . dftRC) a-prop_dftRC_dft2 a = partAbout (dftRC a) (dft . amap (:+0) $ a)-prop_dftRC_dft22 a = partAbout (dftRCN [0,1] a) (dftN [0,1] . amap (:+0) $ a)-prop_dht_idem2 a = aboutIdem (amap (/ fromIntegral (shape a !! 0)) . dht . dht) a--prop_dft3 = aboutIdem $ idft . dft-prop_dft32 = aboutIdem $ idftN [0,1] . dftN [0,1]-prop_dft32' = aboutIdem $ idftN [1,0] . dftN [1,0]-prop_dft33 = aboutIdem $ idftN [0,1,2] . dftN [0,1,2]-prop_dft33' = aboutIdem $ idftN [0,2,1] . dftN [0,2,1]-prop_dft33'' = aboutIdem $ idftN [2,0,1] . dftN [2,0,1]--c_tests :: [(String, CArray Int (Complex Double) -> Bool)]-c_tests = [ ("dft idem 1D" , prop_dft)- ]--c_tests2 :: [(String, CArray (Int,Int) (Complex Double) -> Bool)]-c_tests2 = [ ("dft idem 2D" , prop_dft2)- , ("dft idem 2D/2" , prop_dft22)- , ("dft idem 2D/2'" , prop_dft22')- ]--c_tests3 :: [(String, CArray (Int,Int,Int) (Complex Double) -> Bool)]-c_tests3 = [ ("dft idem 3D" , prop_dft3)- , ("dft idem 3D/2" , prop_dft32)- , ("dft idem 3D/2'" , prop_dft32')- , ("dft idem 3D/3" , prop_dft33)- , ("dft idem 3D/3'" , prop_dft33')- , ("dft idem 3D/3''" , prop_dft33'')- ]--r_tests :: [(String, CArray Int Double -> Bool)]-r_tests = [ ("dftRC/CR idem 1D" , prop_dftRC)- , ("dftRC dft 1D" , prop_dftRC_dft)- , ("dht idem 1D" , prop_dht_idem)- ]--r_tests2 :: [(String, CArray (Int,Int) Double -> Bool)]-r_tests2 = [ ("dftRC/CR idem 2D" , prop_dftRC2)- , ("dftRC dft 2D" , prop_dftRC_dft2)- , ("dftRC dft 2D/2" , prop_dftRC_dft22)- , ("dht idem 2D" , prop_dht_idem2)- ]--main = do- x <- getArgs- let n = if null x then 20 else read . head $ x- conf = Config { configMaxTest = n- , configMaxFail = 1000- , configSize = (+ 3) . (`div` 2)- , configEvery = \n args -> let s = show n in s ++ [ '\b' | _ <- s]- }- mapM_ (\(s,a) -> printf "%-25s: " s >> check conf a) c_tests- mapM_ (\(s,a) -> printf "%-25s: " s >> check conf a) r_tests- mapM_ (\(s,a) -> printf "%-25s: " s >> check conf a) c_tests2- mapM_ (\(s,a) -> printf "%-25s: " s >> check conf a) r_tests2- mapM_ (\(s,a) -> printf "%-25s: " s >> check conf a) c_tests3