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
c745646a
Commit
c745646a
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
ctd: df is a Datafield
parent
438f4db5
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
+19
-19
19 additions, 19 deletions
Device/Resolution/ConvolutionDetectorResolution.cpp
with
19 additions
and
19 deletions
Device/Resolution/ConvolutionDetectorResolution.cpp
+
19
−
19
View file @
c745646a
...
...
@@ -53,13 +53,13 @@ std::vector<const INode*> ConvolutionDetectorResolution::nodeChildren() const
return
std
::
vector
<
const
INode
*>
()
<<
m_res_function_2d
;
}
void
ConvolutionDetectorResolution
::
applyDetectorResolution
(
Datafield
*
intensity_map
)
const
void
ConvolutionDetectorResolution
::
applyDetectorResolution
(
Datafield
*
df
)
const
{
ASSERT
(
intensity_map
->
rank
()
==
m_rank
);
ASSERT
(
df
->
rank
()
==
m_rank
);
if
(
m_rank
==
1
)
apply1dConvolution
(
intensity_map
);
apply1dConvolution
(
df
);
else
if
(
m_rank
==
2
)
apply2dConvolution
(
intensity_map
);
apply2dConvolution
(
df
);
else
ASSERT_NEVER
;
}
...
...
@@ -69,14 +69,14 @@ void ConvolutionDetectorResolution::setResolutionFunction(const IResolutionFunct
m_res_function_2d
.
reset
(
resFunc
.
clone
());
}
void
ConvolutionDetectorResolution
::
apply1dConvolution
(
Datafield
*
intensity_map
)
const
void
ConvolutionDetectorResolution
::
apply1dConvolution
(
Datafield
*
df
)
const
{
ASSERT
(
m_res_function_1d
);
ASSERT
(
intensity_map
->
rank
()
==
1
);
ASSERT
(
df
->
rank
()
==
1
);
const
Scale
&
axis
=
intensity_map
->
axis
(
0
);
const
Scale
&
axis
=
df
->
axis
(
0
);
// Construct source vector from original intensity map
std
::
vector
<
double
>
source_vector
=
intensity_map
->
flatVector
();
std
::
vector
<
double
>
source_vector
=
df
->
flatVector
();
size_t
n
=
source_vector
.
size
();
if
(
n
<
2
)
return
;
// No convolution for sets of zero or one element
...
...
@@ -94,22 +94,22 @@ void ConvolutionDetectorResolution::apply1dConvolution(Datafield* intensity_map)
for
(
double
&
e
:
result
)
e
=
std
::
max
(
0.0
,
e
);
// Populate intensity map with results
intensity_map
->
setVector
(
result
);
df
->
setVector
(
result
);
}
void
ConvolutionDetectorResolution
::
apply2dConvolution
(
Datafield
*
intensity_map
)
const
void
ConvolutionDetectorResolution
::
apply2dConvolution
(
Datafield
*
df
)
const
{
ASSERT
(
m_res_function_2d
);
ASSERT
(
intensity_map
->
rank
()
==
2
);
const
Scale
&
X
=
intensity_map
->
axis
(
0
);
const
Scale
&
Y
=
intensity_map
->
axis
(
1
);
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
=
intensity_map
->
flatVector
();
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
);
...
...
@@ -145,11 +145,11 @@ void ConvolutionDetectorResolution::apply2dConvolution(Datafield* intensity_map)
result_vector
.
push_back
(
value
);
}
}
ASSERT
(
nx
*
ny
==
intensity_map
->
size
());
for
(
size_t
i
=
0
;
i
<
intensity_map
->
size
();
++
i
)
{
size_t
i0
=
intensity_map
->
frame
().
projectedIndex
(
i
,
0
);
size_t
i1
=
intensity_map
->
frame
().
projectedIndex
(
i
,
1
);
(
*
intensity_map
)[
i
]
=
std
::
max
(
0.0
,
result
[
i0
][
i1
]);
ASSERT
(
nx
*
ny
==
df
->
size
());
for
(
size_t
i
=
0
;
i
<
df
->
size
();
++
i
)
{
size_t
i0
=
df
->
frame
().
projectedIndex
(
i
,
0
);
size_t
i1
=
df
->
frame
().
projectedIndex
(
i
,
1
);
(
*
df
)[
i
]
=
std
::
max
(
0.0
,
result
[
i0
][
i1
]);
}
}
...
...
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