JWS C Library
C language utility library
matblock_fft.c File Reference

Declarations for matrix block FFT functions. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include <assert.h>
#include <math.h>
#include "jwsc/matblock/matblock.h"
#include "jwsc/matblock/matblock_math.h"
#include "jwsc/matblock/matblock_fft.h"
Include dependency graph for matblock_fft.c:

Go to the source code of this file.

Functions

expand_symmetric_matblock_dft

Takes advantage of the symmetry propery of the dft on real data: the number of columns in m_in is only half of m_out. More precisely,

 if (ncols_even)
     (*m_out)->num_cols == (m_in->num_cols-1) * 2
 else
     (*m_out)->num_cols == (m_in->num_cols-1) * 2 + 1

See real_to_complex_dft_f() for information on how m_in came to be this way.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inComplex matrix block to convert.
ncols_evenBoolean parameter: 0 if the number of columns in the expanded symmetric m_in is odd; otherwise even.
sScratch Matblock_cf.
Note:
If m_in was already expanded to its symmetry, use shrink_symmetric_matblock_dft_f() to shrink it back before calling this function.
The FFT operations are unnormalized. If doing a real to complex to real dft operation, use scale_matblock_dft_f() to undo the effects of this. Takes advantage of the symmetry propery of the dft on real data: the number of columns in m_in is only half of m_out. More precisely,
 if (ncols_even)
     (*m_out)->num_cols == (m_in->num_cols-1) * 2
 else
     (*m_out)->num_cols == (m_in->num_cols-1) * 2 + 1

See real_to_complex_dft_f() for information on how m_in came to be this way.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inComplex matrix block to convert.
ncols_evenBoolean parameter: 0 if the number of columns in the expanded symmetric m_in is odd; otherwise even.
sScratch Matblock_cd.
Note:
If m_in was already expanded to its symmetry, use shrink_symmetric_matblock_dft_d() to shrink it back before calling this function.
The FFT operations are unnormalized. If doing a real to complex to real dft operation, use scale_matblock_dft_d() to undo the effects of this.

Expands the symmetric columns of a dft.

void expand_symmetric_matblock_dft_f (Matblock_cf **m_out, const Matblock_cf *m_in, uint8_t ncols_even)
 Expands the symmetric columns of a single precision dft.
void expand_symmetric_matblock_dft_d (Matblock_cd **m_out, const Matblock_cd *m_in, uint8_t ncols_even)
 Expands the symmetric columns of a double precision dft.
shrink_symmetric_matblock_dft

Shrinks the symmetric columns of a dft.

void shrink_symmetric_matblock_dft_f (Matblock_cf **m_out, const Matblock_cf *m_in)
 Shrinks the symmetric columns of a single precision dft.
void shrink_symmetric_matblock_dft_d (Matblock_cd **m_out, const Matblock_cd *m_in)
 Shrinks the symmetric columns of a double precision dft.
scale_matblock_dft

Scales the result of a real to complex to real dft operation.

void scale_matblock_dft_f (Matblock_f **m_out, const Matblock_f *m_in)
 Scales the single precision result of a real to complex to real dft operation.
void scale_matblock_dft_d (Matblock_d **m_out, const Matblock_d *m_in)
 Scales the double precision result of a real to complex to real dft operation.
shift_matblock_f

Shifts a matrix block so its diagonal quadrants are swapped.

void shift_matblock_f (Matblock_f **m_out, const Matblock_f *m_in)
 Shifts a single precision matrix block so its diagonal quadrants are swapped.
void shift_matblock_d (Matblock_d **m_out, const Matblock_d *m_in)
 Shifts a double precision matrix block so its diagonal quadrants are swapped.
void shift_matblock_cf (Matblock_cf **m_out, const Matblock_cf *m_in)
 Shifts a single precision complex matrix block so its diagonal quadrants are swapped.
void shift_matblock_cd (Matblock_cd **m_out, const Matblock_cd *m_in)
 Shifts a double precision complex matrix block so its diagonal quadrants are swapped.
unshift_matblock

Unshifts a matrix block that had its diagonal quadrants swapped.

void unshift_matblock_f (Matblock_f **m_out, const Matblock_f *m_in)
 Unshifts a single precision matrix block that had its diagonal quadrants swapped.
void unshift_matblock_d (Matblock_d **m_out, const Matblock_d *m_in)
 Unshifts a double precision matrix block that had its diagonal quadrants swapped.
void unshift_matblock_cf (Matblock_cf **m_out, const Matblock_cf *m_in)
 Unshifts a single precision complex matrix block that had its diagonal quadrants swapped.
void unshift_matblock_cd (Matblock_cd **m_out, const Matblock_cd *m_in)
 Unshifts a double precision complex matrix block that had its diagonal quadrants swapped.

Detailed Description

Declarations for matrix block FFT functions.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

If FFTW3 was built to use SIMD instrinctions, the real to complex and complex to real dft routines are accelerated. For the double precision routines, however, only SSE2 ISA extensions are supported.

Definition in file matblock_fft.c.


Function Documentation

void expand_symmetric_matblock_dft_f ( Matblock_cf **  m_out,
const Matblock_cf m_in,
uint8_t  ncols_even 
)

Expands the symmetric columns of a single precision dft.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inComplex matrix block to expand.
ncols_evenBoolean parameter: 0 if the number of columns to expand m_in to is odd; otherwise even.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 500 of file matblock_fft.c.

void expand_symmetric_matblock_dft_d ( Matblock_cd **  m_out,
const Matblock_cd m_in,
uint8_t  ncols_even 
)

Expands the symmetric columns of a double precision dft.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inComplex matrix block to expand.
ncols_evenBoolean parameter: 0 if the number of columns to expand m_in to is odd; otherwise even.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 560 of file matblock_fft.c.

void shrink_symmetric_matblock_dft_f ( Matblock_cf **  m_out,
const Matblock_cf m_in 
)

Shrinks the symmetric columns of a single precision dft.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inComplex matrix block to shrink.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 630 of file matblock_fft.c.

void shrink_symmetric_matblock_dft_d ( Matblock_cd **  m_out,
const Matblock_cd m_in 
)

Shrinks the symmetric columns of a double precision dft.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inComplex matrix block to expand.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 663 of file matblock_fft.c.

void scale_matblock_dft_f ( Matblock_f **  m_out,
const Matblock_f m_in 
)

Scales the single precision result of a real to complex to real dft operation.

The FFT calculations are unscaled, so doing a real to complex to real operation results in an unscaled real matrix block. This function applies the proper scaling to undo this effect.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to scale.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 711 of file matblock_fft.c.

void scale_matblock_dft_d ( Matblock_d **  m_out,
const Matblock_d m_in 
)

Scales the double precision result of a real to complex to real dft operation.

The FFT calculations are unscaled, so doing a real to complex to real operation results in an unscaled real matrix block. This function applies the proper scaling to undo this effect.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to scale.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 730 of file matblock_fft.c.

void shift_matblock_f ( Matblock_f **  m_out,
const Matblock_f m_in 
)

Shifts a single precision matrix block so its diagonal quadrants are swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to shift.
Note:
If *m_out == m_in, then m_in is overwritten.
Use unshift_matblock_f() to undo the shift.

Definition at line 760 of file matblock_fft.c.

void shift_matblock_d ( Matblock_d **  m_out,
const Matblock_d m_in 
)

Shifts a double precision matrix block so its diagonal quadrants are swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to shift.
Note:
If *m_out == m_in, then m_in is overwritten.
Use unshift_matblock_d() to undo the shift.

Definition at line 898 of file matblock_fft.c.

void shift_matblock_cf ( Matblock_cf **  m_out,
const Matblock_cf m_in 
)

Shifts a single precision complex matrix block so its diagonal quadrants are swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to shift.
Note:
If *m_out == m_in, then m_in is overwritten.
Use unshift_matblock_cf() to undo the shift.

Definition at line 1036 of file matblock_fft.c.

void shift_matblock_cd ( Matblock_cd **  m_out,
const Matblock_cd m_in 
)

Shifts a double precision complex matrix block so its diagonal quadrants are swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to shift.
Note:
If *m_out == m_in, then m_in is overwritten.
Use unshift_matblock_cd() to undo the shift.

Definition at line 1174 of file matblock_fft.c.

void unshift_matblock_f ( Matblock_f **  m_out,
const Matblock_f m_in 
)

Unshifts a single precision matrix block that had its diagonal quadrants swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to unshift.
Note:
If *m_out == m_in, then m_in is overwritten.
Undoes the effects of shift_matblock_f().

Definition at line 1324 of file matblock_fft.c.

void unshift_matblock_d ( Matblock_d **  m_out,
const Matblock_d m_in 
)

Unshifts a double precision matrix block that had its diagonal quadrants swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to unshift.
Note:
If *m_out == m_in, then m_in is overwritten.
Undoes the effects of shift_matblock_d().

Definition at line 1462 of file matblock_fft.c.

void unshift_matblock_cf ( Matblock_cf **  m_out,
const Matblock_cf m_in 
)

Unshifts a single precision complex matrix block that had its diagonal quadrants swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to unshift.
Note:
If *m_out == m_in, then m_in is overwritten.
Undoes the effects of shift_matblock_cf().

Definition at line 1600 of file matblock_fft.c.

void unshift_matblock_cd ( Matblock_cd **  m_out,
const Matblock_cd m_in 
)

Unshifts a double precision complex matrix block that had its diagonal quadrants swapped.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix block is allocated; otherwise its space is re-used.
m_inMatrix block to unshift.
Note:
If *m_out == m_in, then m_in is overwritten.
Undoes the effects of shift_matblock_cd().

Definition at line 1738 of file matblock_fft.c.