Skip to content

"Segmentation fault" when trying to do FFT on 1-element vector. #3

Description

@vi

vector-fftw seems not to like 1-element vectors.

module Main where

import qualified Numeric.FFT.Vector.Unnormalized as FFT
import Data.Vector (fromList, toList)
import Data.List.Split (splitOneOf)
import Data.List (intersperse)
import Control.Monad (forever)
import Control.Arrow ((>>>))

main = forever $
         getLine                      -- read lines
    >>=(   splitOneOf " \t"           -- | split then to chunks on whitespace
    >>>      map read                 -- | | conert them to a list of Doubles
    >>>         fromList              -- | | | convert the list to Vector
    >>>            FFT.run FFT.dct1   -- | | | |  DCT
    >>>         toList                -- | | | convert resulting Vector back to list
    >>>      map show                 -- | | convert each Double back to String
    >>>    intersperse " "            -- | put " " between all chunks
    >>>    concat                     -- | make one happy string from chunks and " "s
    >>>  putStrLn )                   -- output it
$ ghc dct.hs
[1 of 1] Compiling Main             ( dct.hs, dct.o )
Linking dct ...
$ ./dct
1 2 3
8.0 -2.0 0.0
3 0
3.0 3.0
2
Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions