Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
97d07ecc
Commit
97d07ecc
authored
9 years ago
by
Raquel Alvarez Banos
Browse files
Options
Downloads
Patches
Plain Diff
Re #14010 Make ParameterEstimator thread safe
parent
d996b9a7
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/CurveFitting/src/ParameterEstimator.cpp
+31
-7
31 additions, 7 deletions
Framework/CurveFitting/src/ParameterEstimator.cpp
with
31 additions
and
7 deletions
Framework/CurveFitting/src/ParameterEstimator.cpp
+
31
−
7
View file @
97d07ecc
...
...
@@ -7,6 +7,8 @@
#include
"MantidKernel/Logger.h"
#include
<Poco/Timer.h>
#include
<cmath>
namespace
Mantid
{
...
...
@@ -18,20 +20,42 @@ using namespace Functions;
/// The logger.
Kernel
::
Logger
g_log
(
"ParameterEstimator"
);
/// Mutex to prevent simultaneous access to functionMap
static
Poco
::
Mutex
mutex
;
enum
Function
{
None
,
Gaussian
,
Lorentzian
,
BackToBackExponential
};
typedef
std
::
map
<
std
::
string
,
std
::
pair
<
size_t
,
Function
>>
FunctionMapType
;
//----------------------------------------------------------------------------------------------
/// Initializes a FunctionMapType object
/// @param functionMapType :: the function map to initialize
void
initFunctionLookup
(
FunctionMapType
&
functionMapType
)
{
assert
(
functionMapType
.
empty
());
functionMapType
[
"Gaussian"
]
=
std
::
make_pair
(
2
,
Gaussian
);
functionMapType
[
"Lorentzian"
]
=
std
::
make_pair
(
2
,
Lorentzian
);
functionMapType
[
"BackToBackExponential"
]
=
std
::
make_pair
(
4
,
BackToBackExponential
);
}
/// Returns a reference to the static functionMapType
/// @returns :: a const reference to the functionMapType
const
FunctionMapType
&
getFunctionMapType
()
{
Poco
::
Mutex
::
ScopedLock
lock
(
mutex
);
static
FunctionMapType
functionMapType
;
if
(
functionMapType
.
empty
())
initFunctionLookup
(
functionMapType
);
return
functionMapType
;
}
/// Return a function code for a function if it needs setting values or None
/// otherwise.
Function
whichFunction
(
const
API
::
IFunction
&
function
)
{
static
FunctionMapType
functionMap
;
if
(
functionMap
.
empty
())
{
functionMap
[
"Gaussian"
]
=
std
::
make_pair
(
2
,
Gaussian
);
functionMap
[
"Lorentzian"
]
=
std
::
make_pair
(
2
,
Lorentzian
);
functionMap
[
"BackToBackExponential"
]
=
std
::
make_pair
(
4
,
BackToBackExponential
);
}
const
FunctionMapType
&
functionMap
=
getFunctionMapType
();
auto
index
=
functionMap
.
find
(
function
.
name
());
if
(
index
!=
functionMap
.
end
())
{
if
(
!
function
.
isExplicitlySet
(
index
->
second
.
first
))
...
...
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