TDMS
Time Domain Maxwell Solver
Toggle main menu visibility
Loading...
Searching...
No Matches
numerical_derivative.h
Go to the documentation of this file.
1
/**
2
* @file numerical_derivative.h
3
* @brief Functions to calculate the numerical derivatives.
4
*
5
* This code is the main dependency on FFTW3.
6
*/
7
#pragma once
8
9
#include <fftw3.h>
10
11
/**
12
* @brief Multiply two arrays of complex numbers element-wise.
13
*
14
* Performs element-wise complex multiplication of the array a with the array b.
15
* a and b must be must be of equal length.
16
* Stores the result in c.
17
* Internally used by first_derivative.
18
*
19
* @param[in] a Array of complex numbers to multiply with those in b.
20
* @param[in] b Array of complex numbers to multiply with those in a.
21
* @param[out] c The results of the element-wise multiplications a .* b.
22
* @param[in] len The length of the arrays.
23
*/
24
void
complex_mult_vec
(fftw_complex *a, fftw_complex *b, fftw_complex *c,
25
int
len);
26
27
/**
28
* @brief Initialise the coefficients required to simultaneously perform
29
* differentiation and shifting by amount delta, using a forward and backward
30
* FFT.
31
*
32
* @param[in] delta The fraction of the spatial step.
33
* @param[out] Dk Buffer to write the coefficients to.
34
* @param[in] N The number of elements in Dk.
35
*/
36
void
init_diff_shift_op
(
double
delta, fftw_complex *Dk,
int
N);
37
38
/**
39
* @brief Calculate the first derivative of a sampled function.
40
* @note in_pb_pf must be the buffer which is the input for both plans pf and
41
* pb. Likewise, out_pb_pf must be the output for both plans pf and pb.
42
*
43
* @param[in] in_pb_pf The buffer containing the data to be differentiated.
44
* @warning This buffer will be overwritten as part of the computation.
45
* @param[out] out_pb_pf The buffer which will contain the computed derivative.
46
* @param[inout] Dk Buffer to write the coefficients for performing
47
* differentiation and shifting in Fourier space.
48
* @param[in] N Number of elements in buffers.
49
* @param[in] pf The plan for forward FFT.
50
* @param[in] pb The plan for backward FFT.
51
*/
52
void
first_derivative
(fftw_complex *in_pb_pf, fftw_complex *out_pb_pf,
53
fftw_complex *Dk,
int
N, fftw_plan pf, fftw_plan pb);
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.
Definition
numerical_derivative.cpp:18
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...
Definition
numerical_derivative.cpp:30
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.
Definition
numerical_derivative.cpp:63
tdms
include
numerical_derivative.h
Generated by
1.17.0