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

Declarations for matrix FFT functions. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include <assert.h>
#include <math.h>
#include "jwsc/matrix/matrix.h"
#include "jwsc/matrix/matrix_math.h"
Include dependency graph for matrix_fft.c:

Go to the source code of this file.

Functions

expand_symmetric_matrix_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 is allocated; otherwise its space is re-used.
m_inComplex matrix to convert.
ncols_evenBoolean parameter: 0 if the number of columns in the expanded symmetric m_in is odd; otherwise even.
Note:
If m_in was already expanded to its symmetry, use shrink_symmetric_matrix_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_matrix_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 is allocated; otherwise its space is re-used.
m_inComplex matrix to convert.
ncols_evenBoolean parameter: 0 if the number of columns in the expanded symmetric m_in is odd; otherwise even.
Note:
If m_in was already expanded to its symmetry, use shrink_symmetric_matrix_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_matrix_dft_f() to undo the effects of this.

Expands the symmetric columns of a dft.

void expand_symmetric_matrix_dft_f (Matrix_cf **m_out, const Matrix_cf *m_in, uint8_t ncols_even)
 Expands the symmetric columns of a single precision dft.
void expand_symmetric_matrix_dft_d (Matrix_cd **m_out, const Matrix_cd *m_in, uint8_t ncols_even)
 Expands the symmetric columns of a double precision dft.
shrink_symmetric_matrix_dft

Shrinks the symmetric columns of a dft.

void shrink_symmetric_matrix_dft_f (Matrix_cf **m_out, const Matrix_cf *m_in)
 Shrinks the symmetric columns of a single precision dft.
void shrink_symmetric_matrix_dft_d (Matrix_cd **m_out, const Matrix_cd *m_in)
 Shrinks the symmetric columns of a double precision dft.
scale_matrix_dft

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

void scale_matrix_dft_f (Matrix_f **m_out, const Matrix_f *m_in)
 Scales the single precision result of a real to complex to real dft operation.
void scale_matrix_dft_d (Matrix_d **m_out, const Matrix_d *m_in)
 Scales the double precision result of a real to complex to real dft operation.
shift_matrix_f

Shifts a matrix so its diagonal quadrants are swapped.

void shift_matrix_f (Matrix_f **m_out, const Matrix_f *m_in)
 Shifts a single precision matrix so its diagonal quadrants are swapped.
void shift_matrix_d (Matrix_d **m_out, const Matrix_d *m_in)
 Shifts a double precision matrix so its diagonal quadrants are swapped.
void shift_matrix_cf (Matrix_cf **m_out, const Matrix_cf *m_in)
 Shifts a single precision complex matrix so its diagonal quadrants are swapped.
void shift_matrix_cd (Matrix_cd **m_out, const Matrix_cd *m_in)
 Shifts a double precision complex matrix so its diagonal quadrants are swapped.
unshift_matrix

Unshifts a matrix that had its diagonal quadrants swapped.

void unshift_matrix_f (Matrix_f **m_out, const Matrix_f *m_in)
 Unshifts a single precision matrix that had its diagonal quadrants swapped.
void unshift_matrix_d (Matrix_d **m_out, const Matrix_d *m_in)
 Unshifts a double precision matrix that had its diagonal quadrants swapped.
void unshift_matrix_cf (Matrix_cf **m_out, const Matrix_cf *m_in)
 Unshifts a single precision complex matrix that had its diagonal quadrants swapped.
void unshift_matrix_cd (Matrix_cd **m_out, const Matrix_cd *m_in)
 Unshifts a double precision complex matrix that had its diagonal quadrants swapped.

Detailed Description

Declarations for matrix 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 matrix_fft.c.


Function Documentation

void expand_symmetric_matrix_dft_f ( Matrix_cf **  m_out,
const Matrix_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 is allocated; otherwise its space is re-used.
m_inComplex matrix 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 327 of file matrix_fft.c.

void expand_symmetric_matrix_dft_d ( Matrix_cd **  m_out,
const Matrix_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 is allocated; otherwise its space is re-used.
m_inComplex matrix 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 382 of file matrix_fft.c.

void shrink_symmetric_matrix_dft_f ( Matrix_cf **  m_out,
const Matrix_cf m_in 
)

Shrinks the symmetric columns of a single precision dft.

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

Definition at line 446 of file matrix_fft.c.

void shrink_symmetric_matrix_dft_d ( Matrix_cd **  m_out,
const Matrix_cd m_in 
)

Shrinks the symmetric columns of a double precision dft.

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

Definition at line 474 of file matrix_fft.c.

void scale_matrix_dft_f ( Matrix_f **  m_out,
const Matrix_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. This function applies the proper scaling to undo this effect.

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

Definition at line 518 of file matrix_fft.c.

void scale_matrix_dft_d ( Matrix_d **  m_out,
const Matrix_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. This function applies the proper scaling to undo this effect.

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

Definition at line 537 of file matrix_fft.c.

void shift_matrix_f ( Matrix_f **  m_out,
const Matrix_f m_in 
)

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

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

Definition at line 567 of file matrix_fft.c.

void shift_matrix_d ( Matrix_d **  m_out,
const Matrix_d m_in 
)

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

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

Definition at line 647 of file matrix_fft.c.

void shift_matrix_cf ( Matrix_cf **  m_out,
const Matrix_cf m_in 
)

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

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

Definition at line 727 of file matrix_fft.c.

void shift_matrix_cd ( Matrix_cd **  m_out,
const Matrix_cd m_in 
)

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

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

Definition at line 807 of file matrix_fft.c.

void unshift_matrix_f ( Matrix_f **  m_out,
const Matrix_f m_in 
)

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

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

Definition at line 899 of file matrix_fft.c.

void unshift_matrix_d ( Matrix_d **  m_out,
const Matrix_d m_in 
)

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

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

Definition at line 979 of file matrix_fft.c.

void unshift_matrix_cf ( Matrix_cf **  m_out,
const Matrix_cf m_in 
)

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

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

Definition at line 1059 of file matrix_fft.c.

void unshift_matrix_cd ( Matrix_cd **  m_out,
const Matrix_cd m_in 
)

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

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

Definition at line 1139 of file matrix_fft.c.