BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Convolve::Workspace Class Reference

Workspace for Fourier convolution. More...

Public Member Functions

 Workspace ()
 
 ~Workspace ()
 
void clear ()
 

Private Attributes

double * dst_fft
 result of product of FFT(source) and FFT(kernel) More...
 
int h_dst
 
int h_fftw
 
int h_kernel
 
int h_offset
 
int h_src
 
double * in_kernel
 adjusted input 'kernel' array More...
 
double * in_src
 adjusted input 'source' array More...
 
double * out_kernel
 result of Fourier transformation of kernel More...
 
double * out_src
 result of Fourier transformation of source More...
 
fftw_plan p_back
 
fftw_plan p_forw_kernel
 
fftw_plan p_forw_src
 
int w_dst
 
int w_fftw
 
int w_kernel
 
int w_offset
 
int w_src
 

Friends

class Convolve
 

Detailed Description

Workspace for Fourier convolution.

Workspace contains input (source and kernel), intermediate and output arrays to run convolution via fft; 'source' it is our signal, 'kernel' it is our resolution function. Sizes of input arrays are adjusted; output arrays are alocated via fftw3 allocation for maximum performance.

Definition at line 89 of file Convolve.h.

Constructor & Destructor Documentation

◆ Workspace()

Convolve::Workspace::Workspace ( )

Definition at line 28 of file Convolve.cpp.

29  : h_src(0)
30  , w_src(0)
31  , h_kernel(0)
32  , w_kernel(0)
33  , w_fftw(0)
34  , h_fftw(0)
35  , in_src(0)
36  , out_src(0)
37  , in_kernel(0)
38  , out_kernel(0)
39  , dst_fft(0)
40  , h_dst(0)
41  , w_dst(0)
42  ,
43  // dst(0),
44  h_offset(0)
45  , w_offset(0)
46  , p_forw_src(nullptr)
47  , p_forw_kernel(nullptr)
48  , p_back(nullptr)
49 {
50 }
double * out_src
result of Fourier transformation of source
Definition: Convolve.h:104
fftw_plan p_back
Definition: Convolve.h:115
double * in_src
adjusted input 'source' array
Definition: Convolve.h:102
double * in_kernel
adjusted input 'kernel' array
Definition: Convolve.h:106
double * dst_fft
result of product of FFT(source) and FFT(kernel)
Definition: Convolve.h:110
fftw_plan p_forw_src
Definition: Convolve.h:113
fftw_plan p_forw_kernel
Definition: Convolve.h:114
double * out_kernel
result of Fourier transformation of kernel
Definition: Convolve.h:108

◆ ~Workspace()

Convolve::Workspace::~Workspace ( )

Definition at line 52 of file Convolve.cpp.

53 {
54  clear();
55 }

Member Function Documentation

◆ clear()

void Convolve::Workspace::clear ( )

Definition at line 57 of file Convolve.cpp.

58 {
59  h_src = 0;
60  w_src = 0;
61  h_kernel = 0;
62  w_kernel = 0;
63  if (in_src)
64  delete[] in_src;
65  in_src = 0;
66 
67  if (out_src)
68  fftw_free((fftw_complex*)out_src);
69  out_src = 0;
70 
71  if (in_kernel)
72  delete[] in_kernel;
73  in_kernel = 0;
74 
75  if (out_kernel)
76  fftw_free((fftw_complex*)out_kernel);
77  out_kernel = 0;
78 
79  if (dst_fft)
80  delete[] dst_fft;
81  dst_fft = 0;
82 
83  // if(dst) delete[] dst;
84  // dst=0;
85 
86  h_offset = 0;
87  w_offset = 0;
88 
89  if (p_forw_src != nullptr)
90  fftw_destroy_plan(p_forw_src);
91  if (p_forw_kernel != nullptr)
92  fftw_destroy_plan(p_forw_kernel);
93  if (p_back != nullptr)
94  fftw_destroy_plan(p_back);
95 
96  fftw_cleanup();
97 }

Referenced by Convolve::init().

Friends And Related Function Documentation

◆ Convolve

friend class Convolve
friend

Definition at line 94 of file Convolve.h.

Member Data Documentation

◆ dst_fft

double* Convolve::Workspace::dst_fft
private

result of product of FFT(source) and FFT(kernel)

Definition at line 110 of file Convolve.h.

Referenced by Convolve::fftconvolve(), Convolve::fftw_circular_convolution(), and Convolve::init().

◆ h_dst

int Convolve::Workspace::h_dst
private

Definition at line 111 of file Convolve.h.

Referenced by Convolve::fftconvolve(), and Convolve::init().

◆ h_fftw

int Convolve::Workspace::h_fftw
private

◆ h_kernel

int Convolve::Workspace::h_kernel
private

◆ h_offset

int Convolve::Workspace::h_offset
private

Definition at line 112 of file Convolve.h.

Referenced by Convolve::fftconvolve(), and Convolve::init().

◆ h_src

int Convolve::Workspace::h_src
private

Definition at line 97 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ in_kernel

double* Convolve::Workspace::in_kernel
private

adjusted input 'kernel' array

Definition at line 106 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ in_src

double* Convolve::Workspace::in_src
private

adjusted input 'source' array

Definition at line 102 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ out_kernel

double* Convolve::Workspace::out_kernel
private

result of Fourier transformation of kernel

Definition at line 108 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ out_src

double* Convolve::Workspace::out_src
private

result of Fourier transformation of source

Definition at line 104 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ p_back

fftw_plan Convolve::Workspace::p_back
private

Definition at line 115 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ p_forw_kernel

fftw_plan Convolve::Workspace::p_forw_kernel
private

Definition at line 114 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ p_forw_src

fftw_plan Convolve::Workspace::p_forw_src
private

Definition at line 113 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().

◆ w_dst

int Convolve::Workspace::w_dst
private

Definition at line 111 of file Convolve.h.

Referenced by Convolve::fftconvolve(), and Convolve::init().

◆ w_fftw

int Convolve::Workspace::w_fftw
private

◆ w_kernel

int Convolve::Workspace::w_kernel
private

◆ w_offset

int Convolve::Workspace::w_offset
private

Definition at line 112 of file Convolve.h.

Referenced by Convolve::fftconvolve(), and Convolve::init().

◆ w_src

int Convolve::Workspace::w_src
private

Definition at line 97 of file Convolve.h.

Referenced by Convolve::fftw_circular_convolution(), and Convolve::init().


The documentation for this class was generated from the following files: