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
852551b5
Commit
852551b5
authored
2 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
merge ScanAbsoluteResolution into IScanResolution
parent
6b2a1fbc
No related branches found
No related tags found
1 merge request
!1300
Merge IScanResolution and child classes -> ScanResolution
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sim/Scan/ScanResolution.cpp
+14
-49
14 additions, 49 deletions
Sim/Scan/ScanResolution.cpp
Sim/Scan/ScanResolution.h
+16
-13
16 additions, 13 deletions
Sim/Scan/ScanResolution.h
with
30 additions
and
62 deletions
Sim/Scan/ScanResolution.cpp
+
14
−
49
View file @
852551b5
...
...
@@ -17,63 +17,35 @@
#include
"Param/Distrib/ParameterSample.h"
#include
"Param/Distrib/RangedDistributions.h"
namespace
{
// ************************************************************************************************
// ScanAbsoluteResolution
// ************************************************************************************************
class
ScanAbsoluteResolution
:
public
IScanResolution
{
public:
ScanAbsoluteResolution
(
const
IRangedDistribution
&
distr
,
double
stddev
)
:
IScanResolution
(
distr
)
,
m_stddev
(
stddev
)
{
}
~
ScanAbsoluteResolution
()
override
=
default
;
IScanResolution
*
clone
()
const
override
{
return
new
ScanAbsoluteResolution
(
*
rdistribution
(),
m_stddev
);
}
std
::
vector
<
ParameterSample
>
resolutionSamples
(
double
mean
)
const
override
;
std
::
vector
<
double
>
stdDevs
(
double
mean
,
size_t
n_times
)
const
override
;
std
::
vector
<
double
>
stdDevs
(
const
std
::
vector
<
double
>&
mean
)
const
override
;
double
delta
()
const
override
{
return
m_stddev
;
}
IScanResolution
::
IScanResolution
(
const
IRangedDistribution
&
distr
,
double
stddev
)
:
m_distr
(
distr
.
clone
())
,
m_stddev
(
stddev
)
{
}
protected
:
std
::
string
resolutionFactoryName
()
const
override
{
return
"scanAbsoluteResolution"
;
}
IScanResolution
::~
IScanResolution
()
=
default
;
private
:
double
m_stddev
;
//!< deltas for computing resolutions
};
IScanResolution
*
IScanResolution
::
clone
()
const
{
return
new
IScanResolution
(
*
rdistribution
(),
m_stddev
);
}
std
::
vector
<
ParameterSample
>
Scan
Absolute
Resolution
::
resolutionSamples
(
double
mean
)
const
std
::
vector
<
ParameterSample
>
I
ScanResolution
::
resolutionSamples
(
double
mean
)
const
{
return
rdistribution
()
->
generateSamples
(
mean
,
m_stddev
);
}
std
::
vector
<
double
>
Scan
Absolute
Resolution
::
stdDevs
(
double
,
size_t
n_times
)
const
std
::
vector
<
double
>
I
ScanResolution
::
stdDevs
(
double
,
size_t
n_times
)
const
{
return
std
::
vector
<
double
>
(
n_times
,
m_stddev
);
}
std
::
vector
<
double
>
Scan
Absolute
Resolution
::
stdDevs
(
const
std
::
vector
<
double
>&
mean
)
const
std
::
vector
<
double
>
I
ScanResolution
::
stdDevs
(
const
std
::
vector
<
double
>&
mean
)
const
{
ASSERT
(
!
mean
.
empty
());
return
std
::
vector
<
double
>
(
mean
.
size
(),
m_stddev
);
}
}
// namespace
// ************************************************************************************************
// IScanResolution
// ************************************************************************************************
IScanResolution
::~
IScanResolution
()
=
default
;
size_t
IScanResolution
::
nSamples
()
const
{
if
(
m_distr
)
...
...
@@ -81,18 +53,11 @@ size_t IScanResolution::nSamples() const
return
1
;
}
IScanResolution
::
IScanResolution
()
=
default
;
IScanResolution
::
IScanResolution
(
const
IRangedDistribution
&
distr
)
:
m_distr
(
distr
.
clone
())
{
}
// ************************************************************************************************
// Factory functions
// ************************************************************************************************
IScanResolution
*
scanAbsoluteResolution
(
const
IRangedDistribution
&
distr
,
double
stddev
)
{
return
new
Scan
Absolute
Resolution
(
distr
,
stddev
);
return
new
I
ScanResolution
(
distr
,
stddev
);
}
This diff is collapsed.
Click to expand it.
Sim/Scan/ScanResolution.h
+
16
−
13
View file @
852551b5
...
...
@@ -27,37 +27,40 @@ class ParameterSample;
//! Child classes have local scope only (declared and implemented in ScanResolution.cpp);
//! they can only be created through the factory functions declared below.
class
IScanResolution
:
public
ICloneable
{
protected:
using
DistrOutput
=
std
::
vector
<
std
::
vector
<
ParameterSample
>>
;
public:
IScanResolution
(
const
IRangedDistribution
&
distr
,
double
stddev
);
~
IScanResolution
()
override
;
#ifndef SWIG
IScanResolution
*
clone
()
const
override
=
0
;
IScanResolution
*
clone
()
const
override
;
const
IRangedDistribution
*
rdistribution
()
const
{
return
m_distr
.
get
();
}
size_t
nSamples
()
const
;
virtual
std
::
vector
<
ParameterSample
>
resolutionSamples
(
double
mean
)
const
=
0
;
std
::
vector
<
ParameterSample
>
resolutionSamples
(
double
mean
)
const
;
virtual
std
::
vector
<
double
>
stdDevs
(
double
mean
,
size_t
n_times
)
const
=
0
;
virtual
std
::
vector
<
double
>
stdDevs
(
const
std
::
vector
<
double
>&
mean
)
const
=
0
;
std
::
vector
<
double
>
stdDevs
(
double
mean
,
size_t
n_times
)
const
;
std
::
vector
<
double
>
stdDevs
(
const
std
::
vector
<
double
>&
mean
)
const
;
//... For export:
virtual
std
::
string
resolutionFactoryName
()
const
=
0
;
virtual
double
delta
()
const
=
0
;
std
::
string
resolutionFactoryName
()
const
{
return
"scanAbsoluteResolution"
;
}
double
delta
()
const
{
return
m_stddev
;
}
protected
:
IScanResolution
();
IScanResolution
(
const
IRangedDistribution
&
distr
);
private
:
std
::
unique_ptr
<
IRangedDistribution
>
m_distr
;
//!< basic distribution function
double
m_stddev
;
//!< deltas for computing resolutions
#endif // SWIG
};
IScanResolution
*
scanAbsoluteResolution
(
const
IRangedDistribution
&
distr
,
double
stddev
);
#endif // BORNAGAIN_SIM_SCAN_SCANRESOLUTION_H
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