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
294659eb
Commit
294659eb
authored
6 years ago
by
Verena Reimund
Browse files
Options
Downloads
Patches
Plain Diff
Add sortXAxis to unnamed namespace (instead of namespace of the class)
Refs #22197
parent
74eefeac
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h
+0
-2
0 additions, 2 deletions
Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h
Framework/Algorithms/src/Stitch1D.cpp
+49
-51
49 additions, 51 deletions
Framework/Algorithms/src/Stitch1D.cpp
with
49 additions
and
53 deletions
Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h
+
0
−
2
View file @
294659eb
...
...
@@ -89,8 +89,6 @@ private:
Mantid
::
API
::
MatrixWorkspace_sptr
conjoinXAxis
(
Mantid
::
API
::
MatrixWorkspace_sptr
&
inOne
,
Mantid
::
API
::
MatrixWorkspace_sptr
&
inTwo
);
/// Sort x axis
void
sortXAxis
(
Mantid
::
API
::
MatrixWorkspace_sptr
&
ws
);
/// Find the start and end indexes
boost
::
tuple
<
int
,
int
>
findStartEndIndexes
(
double
startOverlap
,
double
endOverlap
,
...
...
This diff is collapsed.
Click to expand it.
Framework/Algorithms/src/Stitch1D.cpp
+
49
−
51
View file @
294659eb
...
...
@@ -28,14 +28,62 @@ using Mantid::HistogramData::HistogramY;
using
Mantid
::
HistogramData
::
Points
;
namespace
{
/// Returns a tuple holding the first and last x value of the first spectrum and
/// the lhs and rhs workspace, respectively
using
MinMaxTuple
=
boost
::
tuple
<
double
,
double
>
;
MinMaxTuple
calculateXIntersection
(
MatrixWorkspace_const_sptr
&
lhsWS
,
MatrixWorkspace_const_sptr
&
rhsWS
)
{
return
MinMaxTuple
(
rhsWS
->
x
(
0
).
front
(),
lhsWS
->
x
(
0
).
back
());
}
/// Check if a double is not zero and returns a bool indicating success
bool
isNonzero
(
double
i
)
{
return
(
0
!=
i
);
}
/** Sort x axis
@param ws :: Input workspace
@return A shared pointer to the resulting MatrixWorkspace
*/
void
sortXAxis
(
MatrixWorkspace_sptr
&
ws
)
{
// using a std::multimap (keys are sorted)
std
::
multimap
<
double
,
double
>
sorter
;
double
x_value
;
const
int
nHists
=
static_cast
<
int
>
(
ws
->
getNumberHistograms
());
for
(
int
i
=
0
;
i
<
nHists
;
++
i
)
{
for
(
size_t
k
=
0
;
k
<
ws
->
size
();
++
k
)
{
x_value
=
ws
->
x
(
i
)[
k
];
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
y
(
i
)[
k
]));
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
e
(
i
)[
k
]));
if
(
ws
->
hasDx
(
i
))
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
dx
(
i
)[
k
]));
}
size_t
ws_size
=
ws
->
size
();
Mantid
::
MantidVec
vecx
(
ws_size
);
Mantid
::
MantidVec
vecy
(
ws_size
);
Mantid
::
MantidVec
vece
(
ws_size
);
Mantid
::
MantidVec
vecdx
(
ws_size
);
int
l
=
0
;
auto
it
=
sorter
.
cbegin
();
while
(
it
!=
sorter
.
cend
())
{
vecx
[
l
]
=
it
->
first
;
vecy
[
l
]
=
it
->
second
;
vece
[
l
]
=
(
++
it
)
->
second
;
if
(
ws
->
hasDx
(
i
))
vecdx
[
l
]
=
(
++
it
)
->
second
;
++
l
;
++
it
;
}
auto
x
=
make_cow
<
HistogramX
>
(
std
::
move
(
vecx
));
auto
y
=
make_cow
<
HistogramY
>
(
std
::
move
(
vecy
));
auto
e
=
make_cow
<
HistogramE
>
(
std
::
move
(
vece
));
ws
->
setSharedX
(
i
,
x
);
ws
->
setSharedY
(
i
,
y
);
ws
->
setSharedE
(
i
,
e
);
if
(
ws
->
hasDx
(
i
))
{
auto
dx
=
make_cow
<
HistogramDx
>
(
std
::
move
(
vecdx
));
ws
->
setSharedDx
(
i
,
dx
);
}
}
}
}
namespace
Mantid
{
...
...
@@ -413,56 +461,6 @@ MatrixWorkspace_sptr Stitch1D::conjoinXAxis(MatrixWorkspace_sptr &inOne,
return
boost
::
dynamic_pointer_cast
<
Mantid
::
API
::
MatrixWorkspace
>
(
ws
);
}
/** Sort x axis
@param ws :: Input workspace
@return A shared pointer to the resulting MatrixWorkspace
*/
void
Stitch1D
::
sortXAxis
(
MatrixWorkspace_sptr
&
ws
)
{
// using a std::multimap (keys are sorted)
std
::
multimap
<
double
,
double
>
sorter
;
double
x_value
;
const
int
nHists
=
static_cast
<
int
>
(
ws
->
getNumberHistograms
());
PARALLEL_FOR_IF
(
Kernel
::
threadSafe
(
*
ws
))
for
(
int
i
=
0
;
i
<
nHists
;
++
i
)
{
PARALLEL_START_INTERUPT_REGION
for
(
size_t
k
=
0
;
k
<
ws
->
size
();
++
k
)
{
x_value
=
ws
->
x
(
i
)[
k
];
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
y
(
i
)[
k
]));
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
e
(
i
)[
k
]));
if
(
ws
->
hasDx
(
i
))
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
dx
(
i
)[
k
]));
}
size_t
ws_size
=
ws
->
size
();
Mantid
::
MantidVec
vecx
(
ws_size
);
Mantid
::
MantidVec
vecy
(
ws_size
);
Mantid
::
MantidVec
vece
(
ws_size
);
Mantid
::
MantidVec
vecdx
(
ws_size
);
int
l
=
0
;
auto
it
=
sorter
.
cbegin
();
while
(
it
!=
sorter
.
cend
())
{
vecx
[
l
]
=
it
->
first
;
vecy
[
l
]
=
it
->
second
;
vece
[
l
]
=
(
++
it
)
->
second
;
if
(
ws
->
hasDx
(
i
))
vecdx
[
l
]
=
(
++
it
)
->
second
;
++
l
;
++
it
;
}
auto
x
=
make_cow
<
HistogramX
>
(
std
::
move
(
vecx
));
auto
y
=
make_cow
<
HistogramY
>
(
std
::
move
(
vecy
));
auto
e
=
make_cow
<
HistogramE
>
(
std
::
move
(
vece
));
ws
->
setSharedX
(
i
,
x
);
ws
->
setSharedY
(
i
,
y
);
ws
->
setSharedE
(
i
,
e
);
if
(
ws
->
hasDx
(
i
))
{
auto
dx
=
make_cow
<
HistogramDx
>
(
std
::
move
(
vecdx
));
ws
->
setSharedDx
(
i
,
dx
);
}
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
}
/** Runs the CreateSingleValuedWorkspace Algorithm as a child
@param val :: The double to convert to a single value workspace
@return A shared pointer to the resulting MatrixWorkspace
...
...
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