forsyde-atom-0.3.0.0: Shallow-embedded DSL for modeling cyber-physical systems
Copyright(c) George Ungureanu KTH/EECS/ESY 2019-2020
LicenseBSD-style (see the file LICENSE)
Maintainerugeorge@kth.se
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

ForSyDe.Atom.Skel.Vector.DSP

Description

This module exports a set of Vector patterns commonly used in signal processing designs.

Synopsis

Documentation

taylor Source #

Arguments

:: (Eq a, Floating a) 
=> Int

number of points in the output window.

-> Int

Number of nearly constant level sidelobes adjacent to the mainlobe

-> a

Desired peak sidelobe level in decibels (db) relative to the mainlobe

-> Vector a

The window, with the center value normalized to one (the value one appears only if the number of samples is odd).

Return the Taylor window. The Taylor window allows for a selectable sidelobe suppression with a minimum broadening. This window is commonly used in radar processing [1]. Code inspired from a pull request for SciPy.

Reference:

[1] W. Carrara, R. Goodman, and R. Majewski "Spotlight Synthetic Aperture Radar: Signal Processing Algorithms" Pages 512-513, July 1995.

taylor' :: (Eq a, Floating a) => p -> a -> Vector a Source #

Returns a Taylor window with default arguments: 4 sidelobes, and peak sidelobe level of -30dB

dotvv :: Num a => Vector a -> Vector a -> a Source #

Calculates the dot product between two vectors.

dotvm :: Num a => Vector a -> Vector (Vector a) -> Vector a Source #

Calculates the dot product between a vector and a matrix

dotvv' Source #

Arguments

:: Num a 
=> ((a -> a -> a) -> f a -> f a -> f a)

higher-order function that can wrap the (*) operation.

-> Vector (f a) 
-> Vector (f a) 
-> f a 

Higher order version of dotvv. Applies dot product on vectors of structured types, e.g. Signals. See dotvv.

dotvm' Source #

Arguments

:: (b -> b -> b)

kernel function for a row/column reduction, e.g. (+) for dot product

-> (a -> b -> b)

binary operation for pair-wise elements, e.g. (*) for dot product

-> Vector a

length = xa

-> Vector (Vector b)

size = (xa,ya)

-> Vector b

length = ya

Higher order version of dotvm. Implements the template for a dot operation between a vector and a matrix.

>>> let mA = vector [vector[1,-1,1],  vector[1,-1,-1],  vector[1,1,-1],  vector[1,1,1]]
>>> let y  = vector[1,0,0,0]
>>> dotVecMat (+) (*) mA y
<1,1,1,1>

dotmv' Source #

Arguments

:: (a -> a -> a)

kernel function for a row/column reduction, e.g. (+) for dot product

-> (b -> a -> a)

binary operation for pair-wise elements, e.g. (*) for dot product

-> Vector (Vector b)

size = (xa,ya)

-> Vector a

length = xa

-> Vector a

length = xa

Higher order pattern implementing the template for a dot operation between a vector and a matrix.

>>> let mA = vector [vector[1,-1,1],  vector[1,-1,-1],  vector[1,1,-1],  vector[1,1,1]]
>>> let y  = vector[1,0,0,0]
>>> dotVecMat (+) (*) mA y
<1,1,1,1>

hanning Source #

Arguments

:: Floating n 
=> Int

The length of the window

-> Vector n 

hamming Source #

Arguments

:: Floating n 
=> Int

The length of the window

-> Vector n 

blackman Source #

Arguments

:: Floating n 
=> Int

The length of the window

-> Vector n 

fir Source #

Arguments

:: Num a 
=> Vector a

vector of coefficients

-> Vector a

input vector of numbers; size = n

-> Vector a

output vector of numbers; size = n

Moving average filter (FIR) on numbers, applied in reverse order (more optimized).

>>> let v = vector [0,0,0,0,0,1]
>>> let c = vector [1,2,3]
>>> fir c
<0,0,0,3,2,1>

fir' Source #

Arguments

:: (a -> a -> a)

process/operation replacing +

-> (c -> a -> a)

process/operation replacing *

-> (a -> a)

delay process

-> Vector c

vector of coefficients

-> a

input signal/structure

-> a

output signal/structure

Higher order version of fir. Can create a systolic FIR process network. See [Ungureanu20a] for a discussion on the relation between fir and fir'.

>>> let c = vector [1,2,3]
>>> let s = SY.signal [1,0,0,0,0,0,0,0]
>>> fir' (SY.comb21 (+)) (\c -> SY.comb11 (*c)) (SY.delay 0) c s
{3,2,1,0,0,0,0,0}

twiddles :: Floating a => Int -> Vector (Complex a) Source #

generates the "twiddle" coefficients for a FFT network.

fft Source #

Arguments

:: RealFloat a 
=> Int

number of FFT stages (== log_2 of length of input vector)

-> Vector (Complex a) 
-> Vector (Complex a) 

Radix-2 decimation-in-frequecy Fast Fourier Transform, applied on numbers. For the difference between DIT- and DIF-FFT, see https://www.slideshare.net/chappidi_saritha/decimation-in-time-and-frequency

fft' Source #

Arguments

:: Floating a 
=> (Complex a -> a -> a -> (a, a))

"butterfly" function.

-> Int

number of FFT stages (== log_2 of length of input vector)

-> Vector a 
-> Vector a 

Higher order version of fft. Takes the "butterfly" function as argument.

butterfly w x0 x1 = let t = w * x1 in (x0 + t, x0 - t)
fft' butterfly === fft

duals :: Vector a -> (Vector a, Vector a) Source #

splits a vector in two equal parts.

>>> duals $ vector [1,2,3,4,5,6,7]
(<1,2,3>,<4,5,6>)

unduals :: Vector a -> Vector a -> Vector a Source #

concatenates a previously split vector. See also duals

bitrev :: Vector a -> Vector a Source #

performs a bit-reverse permutation.

>>> bitrev $ vector ["000","001","010","011","100","101","110","111"]
<"111","011","101","001","110","010","100","000">