Copyright | David Johnson (c) 2019-2020 |
---|---|
License | BSD 3 |
Maintainer | David Johnson <djohnson.m@gmail.com> |
Stability | Experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- approx1 :: AFType a => Array a -> Array a -> InterpType -> Float -> Array a
- approx2 :: AFType a => Array a -> Array a -> Array a -> InterpType -> Float -> Array a
- fft :: (AFType a, Fractional a) => Array a -> Double -> Int -> Array a
- fftInPlace :: (AFType a, Fractional a) => Array (Complex a) -> Double -> IO ()
- fft2 :: AFType a => Array a -> Double -> Int -> Int -> Array a
- fft2_inplace :: (Fractional a, AFType a) => Array (Complex a) -> Double -> IO ()
- fft3 :: AFType a => Array a -> Double -> Int -> Int -> Int -> Array a
- fft3_inplace :: (Fractional a, AFType a) => Array (Complex a) -> Double -> IO ()
- ifft :: AFType a => Array a -> Double -> Int -> Array a
- ifft_inplace :: (AFType a, Fractional a) => Array (Complex a) -> Double -> IO ()
- ifft2 :: AFType a => Array a -> Double -> Int -> Int -> Array a
- ifft2_inplace :: (AFType a, Fractional a) => Array (Complex a) -> Double -> IO ()
- ifft3 :: AFType a => Array a -> Double -> Int -> Int -> Int -> Array a
- ifft3_inplace :: (AFType a, Fractional a) => Array (Complex a) -> Double -> IO ()
- fftr2c :: (Fractional a, AFType a) => Array a -> Double -> Int -> Array a
- fft2r2c :: (Fractional a, AFType a) => Array a -> Double -> Int -> Int -> Array a
- fft3r2c :: (Fractional a, AFType a) => Array a -> Double -> Int -> Int -> Int -> Array a
- fftc2r :: AFType a => Array a -> Double -> Bool -> Array a
- fft2C2r :: AFType a => Array a -> Double -> Bool -> Array a
- fft3C2r :: AFType a => Array a -> Double -> Bool -> Array a
- convolve1 :: AFType a => Array a -> Array a -> ConvMode -> ConvDomain -> Array a
- convolve2 :: AFType a => Array a -> Array a -> ConvMode -> ConvDomain -> Array a
- convolve3 :: AFType a => Array a -> Array a -> ConvMode -> ConvDomain -> Array a
- convolve2Sep :: AFType a => Array a -> Array a -> Array a -> ConvMode -> Array a
- fftConvolve2 :: AFType a => Array a -> Array a -> ConvMode -> Array a
- fftConvolve3 :: AFType a => Array a -> Array a -> ConvMode -> Array a
- fir :: AFType a => Array a -> Array a -> Array a
- iir :: AFType a => Array a -> Array a -> Array a -> Array a
- medFilt :: AFType a => Array a -> Int -> Int -> BorderType -> Array a
- medFilt1 :: AFType a => Array a -> Int -> BorderType -> Array a
- medFilt2 :: AFType a => Array a -> Int -> Int -> BorderType -> Array a
- setFFTPlanCacheSize :: Int -> IO ()
Documentation
:: AFType a | |
=> Array a | the input array |
-> Array a | array contains the interpolation locations |
-> InterpType | is the interpolation type, it can take one of the values defined by |
-> Float | is the value that will set in the output array when certain index is out of bounds |
-> Array a | is the array with interpolated values |
approx1
interpolates data along the first dimensions
Interpolation is performed assuming input data is equally spaced with indices in the range [0, n). The positions are sampled with respect to data at these locations.
>>>
input = vector 3 [10,20,30]
>>>
positions = vector 5 [0.0, 0.5, 1.0, 1.5, 2.0]
>>>
approx1 @Double input positions Cubic 0.0
ArrayFire Array [5 1 1 1] 10.0000 13.7500 20.0000 26.2500 30.0000
:: AFType a | |
=> Array a | is the input array |
-> Array a | array contains the interpolation locations for first dimension |
-> Array a | array contains the interpolation locations for second dimension |
-> InterpType | is the interpolation type, it can take one of the values defined by |
-> Float | is the value that will set in the output array when certain index is out of bounds |
-> Array a | is the array with interpolated values |
approx2 performs interpolation on data along the first and second dimensions.
Interpolation is performed assuming input data is equally spaced with indices in the range [0, n) along each dimension. The positions are sampled with respect to data at these locations.
>>>
input = matrix @Double (3,3) [ [ 1.0,1.0,1.0 ], [ 2.0, 2.0, 2.0 ], [ 3.0,3.0,3.0 ] ]
>>>
positions1 = matrix @Double (2,2) [ [ 0.5,1.5 ],[ 0.5,1.5 ] ]
>>>
positions2 = matrix @Double (2,2) [ [ 0.5,0.5 ],[ 1.5,1.5 ] ]
>>>
approx2 @Double input positions1 positions2 Cubic 0.0
ArrayFire Array [2 2 1 1] 1.3750 1.3750 2.6250 2.6250
:: (AFType a, Fractional a) | |
=> Array a | input |
-> Double | the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals - used to either truncate or pad the input signals. |
-> Array a | is the transformed array |
Fast Fourier Transform
The Fast Fourier Transform (FFT) is an efficient algorithm to compute the discrete Fourier transform (DFT) of a signal or array. This is most commonly used to convert data in the time (or space) domain to the frequency domain, Then, the inverse FFT (iFFT) is used to return the data to the original domain.
>>>
fft (vector @Double 10 [1..]) 2.0 10
ArrayFire Array [2 2 1 1] 1.3750 1.3750 2.6250 2.6250
:: (AFType a, Fractional a) | |
=> Array (Complex a) | is the input array on entry and the output of 1D forward fourier transform at exit |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> IO () |
Fast Fourier Transform (in-place)
C Interface for fast fourier transform on one dimensional signals.
- Note* The input in must be a complex array
:: AFType a | |
=> Array a | the input array |
-> Double | the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals along first dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along second dimension - used to either truncate/pad the input |
-> Array a | the transformed array |
Fast Fourier Transform (2-dimensional)
C Interface for fast fourier transform on two dimensional signals.
:: (Fractional a, AFType a) | |
=> Array (Complex a) | input array on entry and the output of 2D forward fourier transform on exit |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> IO () |
Fast Fourier Transform (2-dimensional, in-place)
C Interface for fast fourier transform on two dimensional signals.
- Note* The input in must be a complex array
:: AFType a | |
=> Array a | the input array |
-> Double | the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals along first dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along second dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along third dimension - used to either truncate/pad the input |
-> Array a | the transformed array |
Fast Fourier Transform (3-dimensional)
C Interface for fast fourier transform on three dimensional signals.
:: (Fractional a, AFType a) | |
=> Array (Complex a) | input array on entry and the output of 3D forward fourier transform on exit |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> IO () |
Fast Fourier Transform (3-dimensional, in-place)
C Interface for fast fourier transform on three dimensional signals.
- Note* The input in must be a complex array
:: AFType a | |
=> Array a | the input array |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals - used to either truncate or pad the input signals |
-> Array a | the transformed array |
Inverse Fast Fourier Transform
C Interface for inverse fast fourier transform on one dimensional signals.
:: (AFType a, Fractional a) | |
=> Array (Complex a) | is the input array on entry and the output of 1D forward fourier transform at exit |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> IO () |
Inverse Fast Fourier Transform (in-place)
C Interface for fast fourier transform on one dimensional signals.
:: AFType a | |
=> Array a | the input array |
-> Double | the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals along first dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along second dimension - used to either truncate/pad the input |
-> Array a | the transformed array |
Inverse Fast Fourier Transform (2-dimensional signals)
C Interface for inverse fast fourier transform on two dimensional signals.
:: (AFType a, Fractional a) | |
=> Array (Complex a) | is the input array on entry and the output of 1D forward fourier transform at exit |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> IO () |
Inverse Fast Fourier Transform (2-dimensional, in-place)
C Interface for fast fourier transform on two dimensional signals.
:: AFType a | |
=> Array a | the input array |
-> Double | the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals along first dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along second dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along third dimension - used to either truncate/pad the input |
-> Array a | the transformed array |
Inverse Fast Fourier Transform (3-dimensional)
C Interface for inverse fast fourier transform on three dimensional signals.
:: (AFType a, Fractional a) | |
=> Array (Complex a) | is the input array on entry and the output of 1D forward fourier transform at exit |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> IO () |
Inverse Fast Fourier Transform (3-dimensional, in-place)
C Interface for fast fourier transform on two dimensional signals.
:: (Fractional a, AFType a) | |
=> Array a | is a real array |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals along first dimension - used to either truncate/pad the input |
-> Array a | is a complex array containing the non redundant parts of in. |
Real to Complex Fast Fourier Transform
C Interface for real to complex fast fourier transform for one dimensional signals.
The first dimension of the output will be of size (pad0 / 2) + 1. The second dimension of the output will be pad1. The third dimension of the output will be pad 2.
:: (Fractional a, AFType a) | |
=> Array a | is a real array |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals along first dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along second dimension - used to either truncate/pad the input |
-> Array a | is a complex array containing the non redundant parts of in. |
Real to Complex Fast Fourier Transform
C Interface for real to complex fast fourier transform for two dimensional signals.
The first dimension of the output will be of size (pad0 / 2) + 1. The second dimension of the output will be pad1. The third dimension of the output will be pad 2.
:: (Fractional a, AFType a) | |
=> Array a | is a real array |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> Int | is the length of output signals along first dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along second dimension - used to either truncate/pad the input |
-> Int | is the length of output signals along third dimension - used to either truncate/pad the input |
-> Array a | is a complex array containing the non redundant parts of in. |
Real to Complex Fast Fourier Transform
C Interface for real to complex fast fourier transform for three dimensional signals.
The first dimension of the output will be of size (pad0 / 2) + 1. The second dimension of the output will be pad1. The third dimension of the output will be pad 2.
:: AFType a | |
=> Array a | is a complex array containing only the non redundant parts of the signals. |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> Bool | is a flag signifying if the output should be even or odd size |
-> Array a | is a real array containing the output of the transform. |
Complex to Real Fast Fourier Transform
C Interface for complex to real fast fourier transform for one dimensional signals.
The first dimension of the output will be 2 * dim0 - 1 if is_odd is true else 2 * dim0 - 2 where dim0 is the first dimension of the input. The remaining dimensions are unchanged.
:: AFType a | |
=> Array a | is a complex array containing only the non redundant parts of the signals. |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> Bool | is a flag signifying if the output should be even or odd size |
-> Array a | is a real array containing the output of the transform. |
Complex to Real Fast Fourier Transform (2-dimensional)
C Interface for complex to real fast fourier transform for two dimensional signals.
The first dimension of the output will be 2 * dim0 - 1 if is_odd is true else 2 * dim0 - 2 where dim0 is the first dimension of the input. The remaining dimensions are unchanged.
:: AFType a | |
=> Array a | is a complex array containing only the non redundant parts of the signals. |
-> Double | is the normalization factor with which the input is scaled after the transformation is applied |
-> Bool | is a flag signifying if the output should be even or odd size |
-> Array a | is a real array containing the output of the transform. |
Complex to Real Fast Fourier Transform (3-dimensional)
C Interface for complex to real fast fourier transform for three dimensional signals.
The first dimension of the output will be 2 * dim0 - 1 if is_odd is true else 2 * dim0 - 2 where dim0 is the first dimension of the input. The remaining dimensions are unchanged.
:: AFType a | |
=> Array a | the input signal |
-> Array a | the signal that shall be flipped for the convolution operation |
-> ConvMode | indicates if the convolution should be expanded or not(where output size equals input) |
-> ConvDomain | specifies if the convolution should be performed in frequency os spatial domain |
-> Array a | convolved array |
Convolution Integral for one dimensional data
C Interface for convolution on one dimensional signals.
- Note* The default parameter of domain, AF_CONV_AUTO, heuristically switches between frequency and spatial domain.
:: AFType a | |
=> Array a | the input signal |
-> Array a | the signal that shall be flipped for the convolution operation |
-> ConvMode | indicates if the convolution should be expanded or not(where output size equals input) |
-> ConvDomain | specifies if the convolution should be performed in frequency os spatial domain |
-> Array a | convolved array |
Convolution Integral for two dimensional data
C Interface for convolution on two dimensional signals.
- Note* The default parameter of domain, AF_CONV_AUTO, heuristically switches between frequency and spatial domain.
:: AFType a | |
=> Array a | the input signal |
-> Array a | the signal that shall be flipped for the convolution operation |
-> ConvMode | indicates if the convolution should be expanded or not(where output size equals input) |
-> ConvDomain | specifies if the convolution should be performed in frequency os spatial domain |
-> Array a | convolved array |
Convolution Integral for three dimensional data
C Interface for convolution on three dimensional signals.
- Note* The default parameter of domain, AF_CONV_AUTO, heuristically switches between frequency and spatial domain.
:: AFType a | |
=> Array a | filter that has to be applied along the coloumns |
-> Array a | filter that has to be applied along the rows |
-> Array a | the input array |
-> ConvMode | indicates if the convolution should be expanded or not(where output size equals input) |
-> Array a | convolved array |
C Interface for separable convolution on two dimensional signals.
C Interface for separable convolution on two dimensional signals.
- Note* The default parameter of domain, AF_CONV_AUTO, heuristically switches between frequency and spatial domain.
:: AFType a | |
=> Array a | is the input signal |
-> Array a | |
-> ConvMode | indicates if the convolution should be expanded or not(where output size equals input) |
-> Array a | is convolved array |
2D Convolution using Fast Fourier Transform
A convolution is a common operation between a source array, a, and a filter (or kernel) array b. The answer to the convolution is the same as computing the coefficients in polynomial multiplication, if a and b are the coefficients.
C Interface for FFT-based convolution on two dimensional signals.
:: AFType a | |
=> Array a | is the input signal |
-> Array a | |
-> ConvMode | indicates if the convolution should be expanded or not(where output size equals input) |
-> Array a | is convolved array |
3D Convolution using Fast Fourier Transform
A convolution is a common operation between a source array, a, and a filter (or kernel) array b. The answer to the convolution is the same as computing the coefficients in polynomial multiplication, if a and b are the coefficients.
C Interface for FFT-based convolution on three dimensional signals.
:: AFType a | |
=> Array a | is the input signal to the filter |
-> Array a | is the array containing the coefficients of the filter |
-> Array a | is the output signal from the filter |
Finite Impulse Filter.
Finite impulse filters take an input x and a co-efficient array b to generate an output y such that:
C Interface for finite impulse response filter.
:: AFType a | |
=> Array a | the array containing the feedforward coefficient |
-> Array a | is the array containing the feedback coefficients |
-> Array a | is the input signal to the filter |
-> Array a | the output signal from the filter |
Infinite Impulse Filter.
Infinite impulse filters take an input x and a feedforward array b, feedback array a to generate an output y such that:
C Interface for infinite impulse response filter.
- Note* The feedforward coefficients are currently limited to a length of 512
:: AFType a | |
=> Array a |
|
-> Int | |
-> Int | |
-> BorderType | |
-> Array a |
|
Median Filter
A median filter is similar to the arbitrary filter except that instead of a weighted sum, the median value of the pixels covered by the kernel is returned.
C Interface for median filter.
:: AFType a | |
=> Array a |
|
-> Int | Is the kernel width |
-> BorderType | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM] |
-> Array a |
|
1D Median Filter
A median filter is similar to the arbitrary filter except that instead of a weighted sum, the median value of the pixels covered by the kernel is returned.
C Interface for 1D median filter.
:: AFType a | |
=> Array a |
|
-> Int | the kernel height |
-> Int | the kernel width |
-> BorderType | value will decide what happens to border when running filter in their neighborhood. It takes one of the values [AF_PAD_ZERO | AF_PAD_SYM] |
-> Array a |
|
2D Median Filter
A median filter is similar to the arbitrary filter except that instead of a weighted sum, the median value of the pixels covered by the kernel is returned.
C Interface for 2D median filter.
C Interface for setting plan cache size.
This function doesn't do anything if called when CPU backend is active. The plans associated with the most recently used array sizes are cached.
>>>
setFFTPlanCacheSize 2
()