TDMS
Time Domain Maxwell Solver
All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
numerical_derivative.h File Reference

Functions to calculate the numerical derivatives. More...

#include <fftw3.h>
Include dependency graph for numerical_derivative.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void complex_mult_vec (fftw_complex *a, fftw_complex *b, fftw_complex *c, int len)
 Multiply two arrays of complex numbers element-wise.
 
void init_diff_shift_op (double delta, fftw_complex *Dk, int N)
 Initialise the coefficients required to simultaneously perform differentiation and shifting by amount delta, using a forward and backward FFT.
 
void first_derivative (fftw_complex *in_pb_pf, fftw_complex *out_pb_pf, fftw_complex *Dk, int N, fftw_plan pf, fftw_plan pb)
 Calculate the first derivative of a sampled function.
 

Detailed Description

Functions to calculate the numerical derivatives.

This code is the main dependency on FFTW3.

Function Documentation

◆ complex_mult_vec()

void complex_mult_vec ( fftw_complex *  a,
fftw_complex *  b,
fftw_complex *  c,
int  len 
)

Multiply two arrays of complex numbers element-wise.

Performs element-wise complex multiplication of the array a with the array b. a and b must be must be of equal length. Stores the result in c. Internally used by first_derivative.

Parameters
[in]aArray of complex numbers to multiply with those in b.
[in]bArray of complex numbers to multiply with those in a.
[out]cThe results of the element-wise multiplications a .* b.
[in]lenThe length of the arrays.

◆ first_derivative()

void first_derivative ( fftw_complex *  in_pb_pf,
fftw_complex *  out_pb_pf,
fftw_complex *  Dk,
int  N,
fftw_plan  pf,
fftw_plan  pb 
)

Calculate the first derivative of a sampled function.

Note
in_pb_pf must be the buffer which is the input for both plans pf and pb. Likewise, out_pb_pf must be the output for both plans pf and pb.
Parameters
[in]in_pb_pfThe buffer containing the data to be differentiated.
Warning
This buffer will be overwritten as part of the computation.
Parameters
[out]out_pb_pfThe buffer which will contain the computed derivative.
[in,out]DkBuffer to write the coefficients for performing differentiation and shifting in Fourier space.
[in]NNumber of elements in buffers.
[in]pfThe plan for forward FFT.
[in]pbThe plan for backward FFT.

◆ init_diff_shift_op()

void init_diff_shift_op ( double  delta,
fftw_complex *  Dk,
int  N 
)

Initialise the coefficients required to simultaneously perform differentiation and shifting by amount delta, using a forward and backward FFT.

Parameters
[in]deltaThe fraction of the spatial step.
[out]DkBuffer to write the coefficients to.
[in]NThe number of elements in Dk.