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

Function getRhoJ

Applications/HHL_Algorithm/BasicFunctionByOrigin.cpp:163–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163int getRhoJ(VectorXd& r, double dd, vector<int>& No0Ind, vector<int>& SpIni, MatrixXd& Ae) {
164
165 int size = r.size();
166 int rows = Ae.rows();
167
168 VectorXd r_all(rows);
169 vector<int> Jset;
170 //vector<int> JsetNew;
171
172 for (int i = 0; i < size; i++) {
173 if (r(i) != 0) {
174 Jset.push_back(No0Ind[i]);
175 }
176 }
177
178 for (auto it = SpIni.begin(); it != SpIni.end(); ++it) {
179 Jset.erase(std::remove(Jset.begin(), Jset.end(), *it), Jset.end());
180 }
181
182 MatrixXd sA(rows, No0Ind.size());
183 for (int i = 0; i < No0Ind.size(); i++) {
184 sA.col(i) = Ae.col(No0Ind[i]);
185 }
186 //vector<double> rho_j;
187
188 double min_rho = 10;
189 int J_add=0;
190 for (int j = 0; j < Jset.size(); j++) {
191
192 auto up = pow(r.dot(sA.row(Jset[j])), 2);
193 auto down = pow(sA.row(Jset[j]).norm(), 2);
194 auto rho = dd * dd - up / down;
195 if (rho < min_rho) {
196 min_rho = rho;
197 J_add = j;
198 }
199 }
200 return Jset[J_add];
201}
202
203int getRhoJ(VectorXd& r, double dd, vector<int>& No0Ind, vector<int>& SpIni, SparseQMatrix<double>& Ae) {
204

Callers 1

Calls 12

powFunction · 0.50
sizeMethod · 0.45
rowsMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
colMethod · 0.45
dotMethod · 0.45
rowMethod · 0.45
normMethod · 0.45

Tested by

no test coverage detected