Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
616280e5
Commit
616280e5
authored
May 26, 2020
by
Mccaskey, Alex
Browse files
fixing bug in qalloc qreg weighted_sum, removing I buffer from computation
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
53391ec2
Pipeline
#103847
passed with stage
in 68 minutes and 53 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
xacc/compiler/qalloc.cpp
View file @
616280e5
...
...
@@ -43,15 +43,27 @@ double qreg::weighted_sum(Observable *obs) {
auto
id
=
obs
->
getIdentitySubTerm
();
auto
children
=
buffer
->
getChildren
();
double
sum
=
0.0
;
if
(
terms
.
size
()
!=
children
.
size
())
{
xacc
::
error
(
"[qreg::weighted_sum()] error, number of observable terms != "
"number of children buffers."
);
if
(
terms
.
size
()
+
1
==
children
.
size
())
{
// find the I term in children and remove it
// we will add it at the end
children
.
erase
(
std
::
remove_if
(
children
.
begin
(),
children
.
end
(),
[](
const
auto
&
child
)
{
return
child
->
name
()
==
"I"
;
}),
children
.
end
());
}
else
{
xacc
::
error
(
"[qreg::weighted_sum()] error, number of observable terms != "
"number of children buffers."
);
}
}
for
(
int
i
=
0
;
i
<
children
.
size
();
i
++
)
{
// std::cout << children[i]->name() << ", "
//
<< children[i]->getExpectationValueZ() << ", "
// std::cout << children[i]->name() << ", "
;
//
std::cout
<< children[i]->getExpectationValueZ() << ", "
// << terms[i]->coefficient() << "\n";
sum
+=
children
[
i
]
->
getExpectationValueZ
()
*
...
...
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