MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / findNonConsts

Method findNonConsts

Core/Variational/expression.cpp:92–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92std::vector<var> expression::findNonConsts(const std::vector<var>& leaves){
93 std::vector<var> nonconsts;
94 std::queue<var> q;
95 for(const var& v : leaves)
96 q.push(v);
97
98 while(!q.empty()){
99 var v = q.front();
100 q.pop();
101
102 if (std::end(nonconsts) != std::find(std::begin(nonconsts), std::end(nonconsts), v))
103 continue;
104
105 nonconsts.emplace_back(v);
106 std::vector<var> parents = v.getParents();
107 for(const var& parent : parents){
108 q.push(parent);
109 }
110 }
111 return nonconsts;
112}
113
114//copied from std::vector<var> expression::findNonConsts(const std::vector<var>& leaves)
115std::vector<var> expression::findNonConsts(const std::unordered_set<var>& leaves) {

Callers 3

TESTFunction · 0.80
compute_gradientsMethod · 0.80
runMethod · 0.80

Calls 7

frontMethod · 0.80
getParentsMethod · 0.80
findFunction · 0.50
pushMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45
emplace_backMethod · 0.45

Tested by 1

TESTFunction · 0.64