Copyright | (c) Matthew Donadio 1998 |
---|---|

License | GPL |

Maintainer | m.p.donadio@ieee.org |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell98 |

Basic functions for manipulating signals

## Synopsis

- linspace :: Double -> Double -> Int -> [Double]
- logspace :: Double -> Double -> Int -> [Double]
- delay1 :: Num a => [a] -> [a]
- delay :: Num a => Int -> [a] -> [a]
- downsample :: Int -> [a] -> [a]
- downsampleRec :: Int -> [a] -> [a]
- upsample :: Num a => Int -> [a] -> [a]
- upsampleRec :: Num a => Int -> [a] -> [a]
- upsampleAndHold :: Int -> [a] -> [a]
- interleave :: [a] -> [a] -> [a]
- uninterleave :: [a] -> ([a], [a])
- pad :: (Ix a, Integral a, Num b) => Array a b -> a -> Array a b
- toMaybe :: Bool -> a -> Maybe a
- norm2sqr :: Num a => (a, a) -> a
- (^!) :: Num a => a -> Int -> a

# Functions

linspace :: Double -> Double -> Int -> [Double] Source #

`linspace`

generates a list of values linearly spaced between specified
start and end values (array will include both start and end values).

linspace 0.0 1.0 5 == [ 0.0, 0.25, 0.5, 0.75 1.0 ]

logspace :: Double -> Double -> Int -> [Double] Source #

`logspace`

generates a list of values logarithmically spaced between the
values 10 ** start and 10 ** end (array will include both start and end values).

logspace 0.0 1.0 4 == [ 1.0, 2.1544, 4.6416, 10.0 ]

delay1 :: Num a => [a] -> [a] Source #

`delay`

is the unit delay function, eg,

delay1 [ 1, 2, 3 ] == [ 0, 1, 2, 3 ]

delay :: Num a => Int -> [a] -> [a] Source #

`delay`

is the n sample delay function, eg,

delay 3 [ 1, 2, 3 ] == [ 0, 0, 0, 1, 2, 3 ]

downsample :: Int -> [a] -> [a] Source #

`downsample`

throws away every n'th sample, eg,

downsample 2 [ 1, 2, 3, 4, 5, 6 ] == [ 1, 3, 5 ]

downsampleRec :: Int -> [a] -> [a] Source #

upsample :: Num a => Int -> [a] -> [a] Source #

`upsample`

inserts n-1 zeros between each sample, eg,

upsample 2 [ 1, 2, 3 ] == [ 1, 0, 2, 0, 3, 0 ]

upsampleRec :: Num a => Int -> [a] -> [a] Source #

upsampleAndHold :: Int -> [a] -> [a] Source #

`upsampleAndHold`

replicates each sample n times, eg,

upsampleAndHold 3 [ 1, 2, 3 ] == [ 1, 1, 1, 2, 2, 2, 3, 3, 3 ]

interleave :: [a] -> [a] -> [a] Source #

merges elements from two lists into one list in an alternating way

interleave [0,1,2,3] [10,11,12,13] == [0,10,1,11,2,12,3,13]

uninterleave :: [a] -> ([a], [a]) Source #

split a list into two lists in an alternating way

uninterleave [1,2,3,4,5,6] == ([1,3,5],[2,4,6])

It's a special case of `split`

.