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
e688fe92
Commit
e688fe92
authored
May 26, 2020
by
Nguyen, Thien Minh
Browse files
Merge branch 'master' into tnguyen/qcor
parents
35fa737d
616280e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
xacc/compiler/qalloc.cpp
View file @
e688fe92
...
...
@@ -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