hsignal 0.1.2.3 → 0.1.2.4
raw patch · 5 files changed
+30/−31 lines, 5 files
Files
- CHANGES +3/−0
- hsignal.cabal +4/−3
- lib/Numeric/Signal.hs +3/−7
- lib/Numeric/Signal/Internal.hs +11/−10
- lib/Numeric/Signal/Multichannel.hs +9/−11
CHANGES view
@@ -42,3 +42,6 @@ 0.1.2.3: changes to reflect new hmatrix interface ++0.1.2.4:+ changes ro reflect new hmatrix interface
hsignal.cabal view
@@ -1,12 +1,12 @@ Name: hsignal-Version: 0.1.2.3+Version: 0.1.2.4 License: BSD3 License-file: LICENSE Author: Vivian McPhail Maintainer: haskell.vivian.mcphail <at> gmail <dot> com Stability: provisional Homepage: http://code.haskell.org/hsignal-Synopsis: Signal processing+Synopsis: Signal processing and EEG data analysis Description: Purely functional interface to signal processing based on hmatrix . @@ -44,6 +44,7 @@ Numeric.Signal.EEG other-modules: Numeric.Signal.Internal Numeric.Signal.EEG.BDF+ C-sources: lib/Numeric/Signal/signal-aux.c ghc-prof-options: -auto@@ -66,5 +67,5 @@ source-repository head type: darcs- location: http://code.haskell.org/hsignal+ location: darcs get http://code.haskell.org/hsignal
lib/Numeric/Signal.hs view
@@ -40,14 +40,10 @@ import qualified Data.List as L -import Data.Packed.Vector-import Data.Packed(Container(..))-+--import Data.Packed.Vector+--import Data.Packed(Container(..))+import Numeric.Vector import Numeric.GSL.Vector----import Numeric.LinearAlgebra.Algorithms-import Numeric.LinearAlgebra.Linear---import Numeric.LinearAlgebra.Interface import qualified Numeric.GSL.Fourier as F
lib/Numeric/Signal/Internal.hs view
@@ -27,15 +27,16 @@ ) where import Data.Packed.Development(createVector,vec,app1,app2,app3,app4)-import Data.Packed.Vector-import Data.Packed(Container(..))+--import Data.Packed.Vector+import Numeric.Container+import Numeric.Vector --import Numeric.LinearAlgebra.Algorithms-import Numeric.LinearAlgebra.Linear+--import Numeric.LinearAlgebra.Linear import qualified Numeric.GSL.Fourier as F import Foreign-import Data.Complex+--import Data.Complex import Foreign.C.Types import Prelude hiding(filter)@@ -54,7 +55,7 @@ ----------------------------------------------------------------------------- instance Convolvable (Vector Double) where- convolve x y = fst $ fromComplex $ F.ifft $ (F.fft (comp x) * F.fft (comp y))+ convolve x y = fst $ fromComplex $ F.ifft $ (F.fft (complex x) * F.fft (complex y)) -- convolve = convolve_vector_double convolve_vector_double c a = unsafePerformIO $ do@@ -96,8 +97,8 @@ -- | Hilbert transform with original vector as real value, transformed as imaginary hilbert :: Vector Double -> Vector (Complex Double) hilbert v = unsafePerformIO $ do- let r = comp v- -- could use (comp v) to make a complex vector in haskell rather than C+ let r = complex v+ -- could use (complex v) to make a complex vector in haskell rather than C app1 signal_hilbert vec r "hilbert" return r @@ -111,7 +112,7 @@ -> Vector Double -- ^ power density pwelch w v = unsafePerformIO $ do let r = constant 0.0 ((w `div` 2) + 1)- app2 (signal_pwelch $ fromIntegral w) vec (comp v) vec r "pwelch"+ app2 (signal_pwelch $ fromIntegral w) vec (complex v) vec r "pwelch" return r foreign import ccall "signal-aux.h pwelch" signal_pwelch :: CInt -> CInt -> PC -> CInt -> PD -> IO CInt@@ -138,8 +139,8 @@ -> Vector Double -- ^ points (between 0 and 2*pi) -> Vector Double -- ^ response freqz b a w = let k = max (dim b) (dim a)- hb = polyEval (postpad b k) (exp (scale (0 :+ 1) ((comp w) :: Vector (Complex Double))))- ha = polyEval (postpad a k) (exp (scale (0 :+ 1) ((comp w) :: Vector (Complex Double))))+ hb = polyEval (postpad b k) (exp (scale (0 :+ 1) ((complex w) :: Vector (Complex Double))))+ ha = polyEval (postpad a k) (exp (scale (0 :+ 1) ((complex w) :: Vector (Complex Double)))) in complex_power (hb / ha) postpad v n = let d = dim v
lib/Numeric/Signal/Multichannel.hs view
@@ -45,17 +45,12 @@ --import qualified Data.List as L -import Data.Packed.Vector-import Data.Packed.Matrix---import Data.Packed(Container(..))- import Data.Binary import Foreign.Storable---import Numeric.GSL.Vector -import Numeric.LinearAlgebra.Linear---import Numeric.LinearAlgebra.Algorithms+import Numeric.Vector+import Numeric.Matrix --import qualified Numeric.GSL.Fourier as F @@ -102,7 +97,8 @@ instance (Binary a, Storable a, Ord a, RealFrac a,- Vectors Vector a) => Binary (Multichannel a) where+ Container Vector a,+ Product a) => Binary (Multichannel a) where put (MC s p c l de f d) = do put s put p@@ -111,7 +107,7 @@ put de put f put $! fmap convert d- where convert v = let (mi,ma) = (vectorMin v,vectorMax v)+ where convert v = let (mi,ma) = (minElement v,maxElement v) v' = mapVector (\x -> round $ (x - mi)/(ma - mi) * (fromIntegral (maxBound :: Word32))) v in (mi,ma,(v' :: Vector Word32)) @@ -132,12 +128,14 @@ readMultichannel :: (Binary a, Storable a, Ord a, RealFrac a,- Vectors Vector a) => FilePath -> IO (Multichannel a)+ Container Vector a,+ Product a) => FilePath -> IO (Multichannel a) readMultichannel = decodeFile writeMultichannel :: (Binary a, Storable a, Ord a, RealFrac a,- Vectors Vector a) => FilePath -> Multichannel a -> IO ()+ Container Vector a,+ Product a) => FilePath -> Multichannel a -> IO () writeMultichannel = encodeFile -----------------------------------------------------------------------------