Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
d8698dec
Unverified
Commit
d8698dec
authored
Mar 24, 2020
by
Peterson, Peter
Committed by
GitHub
Mar 24, 2020
Browse files
Merge pull request #28196 from mantidproject/faster_plus_minus
Avoid extra multiply in Plus and Minus
parents
ecd6193f
683f6c22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Framework/Algorithms/src/Minus.cpp
View file @
d8698dec
...
...
@@ -22,7 +22,7 @@ void Minus::performBinaryOperation(const HistogramData::Histogram &lhs,
HistogramData
::
HistogramY
&
YOut
,
HistogramData
::
HistogramE
&
EOut
)
{
std
::
transform
(
lhs
.
y
().
begin
(),
lhs
.
y
().
end
(),
rhs
.
y
().
begin
(),
YOut
.
begin
(),
std
::
minus
<
double
>
());
std
::
minus
<>
());
std
::
transform
(
lhs
.
e
().
begin
(),
lhs
.
e
().
end
(),
rhs
.
e
().
begin
(),
EOut
.
begin
(),
VectorHelper
::
SumGaussError
<
double
>
());
}
...
...
@@ -33,12 +33,13 @@ void Minus::performBinaryOperation(const HistogramData::Histogram &lhs,
HistogramData
::
HistogramE
&
EOut
)
{
using
std
::
placeholders
::
_1
;
std
::
transform
(
lhs
.
y
().
begin
(),
lhs
.
y
().
end
(),
YOut
.
begin
(),
std
::
bind
(
std
::
minus
<
double
>
(),
_1
,
rhsY
)
);
[
rhsY
](
double
l
)
{
return
l
-
rhsY
;
}
);
// Only do E if non-zero, otherwise just copy
if
(
rhsE
!=
0
)
if
(
rhsE
!=
0
)
{
double
rhsE2
=
rhsE
*
rhsE
;
std
::
transform
(
lhs
.
e
().
begin
(),
lhs
.
e
().
end
(),
EOut
.
begin
(),
std
::
bind
(
VectorHelper
::
SumGaussError
<
double
>
(),
_1
,
rhsE
)
);
else
[
rhsE2
](
double
l
)
{
return
std
::
sqrt
(
l
*
l
+
rhsE2
);
}
);
}
else
EOut
=
lhs
.
e
();
}
...
...
Framework/Algorithms/src/Plus.cpp
View file @
d8698dec
...
...
@@ -24,7 +24,7 @@ void Plus::performBinaryOperation(const HistogramData::Histogram &lhs,
HistogramData
::
HistogramY
&
YOut
,
HistogramData
::
HistogramE
&
EOut
)
{
std
::
transform
(
lhs
.
y
().
begin
(),
lhs
.
y
().
end
(),
rhs
.
y
().
begin
(),
YOut
.
begin
(),
std
::
plus
<
double
>
());
std
::
plus
<>
());
std
::
transform
(
lhs
.
e
().
begin
(),
lhs
.
e
().
end
(),
rhs
.
e
().
begin
(),
EOut
.
begin
(),
VectorHelper
::
SumGaussError
<
double
>
());
}
...
...
@@ -36,12 +36,14 @@ void Plus::performBinaryOperation(const HistogramData::Histogram &lhs,
HistogramData
::
HistogramE
&
EOut
)
{
using
std
::
placeholders
::
_1
;
std
::
transform
(
lhs
.
y
().
begin
(),
lhs
.
y
().
end
(),
YOut
.
begin
(),
std
::
bind
(
std
::
plus
<
double
>
(),
_1
,
rhsY
)
);
[
rhsY
](
double
l
)
{
return
l
+
rhsY
;
}
);
// Only do E if non-zero, otherwise just copy
if
(
rhsE
!=
0
)
if
(
rhsE
!=
0.
)
{
double
rhsE2
=
rhsE
*
rhsE
;
std
::
transform
(
lhs
.
e
().
begin
(),
lhs
.
e
().
end
(),
EOut
.
begin
(),
std
::
bind
(
VectorHelper
::
SumGaussError
<
double
>
(),
_1
,
rhsE
)
);
else
[
rhsE2
](
double
l
)
{
return
std
::
sqrt
(
l
*
l
+
rhsE2
);
}
);
}
else
EOut
=
lhs
.
e
();
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment