Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
ed1205a7
Commit
ed1205a7
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
simpler access to df
parent
c745646a
No related branches found
No related tags found
1 merge request
!2020
convolution computation more compact
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Device/Resolution/ConvolutionDetectorResolution.cpp
+8
-17
8 additions, 17 deletions
Device/Resolution/ConvolutionDetectorResolution.cpp
with
8 additions
and
17 deletions
Device/Resolution/ConvolutionDetectorResolution.cpp
+
8
−
17
View file @
ed1205a7
...
...
@@ -75,11 +75,10 @@ void ConvolutionDetectorResolution::apply1dConvolution(Datafield* df) const
ASSERT
(
df
->
rank
()
==
1
);
const
Scale
&
axis
=
df
->
axis
(
0
);
// Construct source vector from original intensity map
std
::
vector
<
double
>
source_vector
=
df
->
flatVector
();
size_t
n
=
source_vector
.
size
();
const
size_t
n
=
df
->
size
();
if
(
n
<
2
)
return
;
// No convolution for sets of zero or one element
// Construct kernel vector from resolution function
ASSERT
(
axis
.
size
()
==
n
);
double
step_size
=
std
::
abs
(
axis
.
binCenter
(
0
)
-
axis
.
binCenter
(
n
-
1
))
/
(
n
-
1
);
...
...
@@ -89,7 +88,7 @@ void ConvolutionDetectorResolution::apply1dConvolution(Datafield* df) const
kernel
.
push_back
(
getIntegratedPDF1d
(
axis
.
binCenter
(
index
)
-
mid_value
,
step_size
));
// Calculate convolution
std
::
vector
<
double
>
result
;
Convolve
().
fftconvolve
(
source_v
ector
,
kernel
,
result
);
Convolve
().
fftconvolve
(
df
->
flatV
ector
()
,
kernel
,
result
);
// Truncate negative values that can arise because of finite precision of Fourier Transform
for
(
double
&
e
:
result
)
e
=
std
::
max
(
0.0
,
e
);
...
...
@@ -103,18 +102,10 @@ void ConvolutionDetectorResolution::apply2dConvolution(Datafield* df) const
ASSERT
(
df
->
rank
()
==
2
);
const
Scale
&
X
=
df
->
axis
(
0
);
const
Scale
&
Y
=
df
->
axis
(
1
);
size_t
nx
=
X
.
size
();
size_t
ny
=
Y
.
size
();
ASSERT
(
nx
>
1
);
ASSERT
(
ny
>
1
);
// Construct source vector array from original intensity map
std
::
vector
<
double
>
raw_source_vector
=
df
->
flatVector
();
std
::
vector
<
std
::
vector
<
double
>>
source
;
size_t
raw_data_size
=
raw_source_vector
.
size
();
ASSERT
(
raw_data_size
==
nx
*
ny
);
for
(
auto
it
=
raw_source_vector
.
begin
();
it
!=
raw_source_vector
.
end
();
it
+=
ny
)
source
.
emplace_back
(
std
::
vector
<
double
>
(
it
,
it
+
ny
));
const
size_t
nx
=
X
.
size
();
const
size_t
ny
=
Y
.
size
();
if
(
nx
<
2
&&
ny
<
2
)
return
;
// Construct kernel vector from resolution function
std
::
vector
<
std
::
vector
<
double
>>
kernel
;
...
...
@@ -135,7 +126,7 @@ void ConvolutionDetectorResolution::apply2dConvolution(Datafield* df) const
}
// Calculate convolution
std
::
vector
<
std
::
vector
<
double
>>
result
;
Convolve
().
fftconvolve
(
source
,
kernel
,
result
);
Convolve
().
fftconvolve
(
df
->
values2D
()
,
kernel
,
result
);
// Populate intensity map with results
std
::
vector
<
double
>
result_vector
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment