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

Function getSubMatrix

Applications/HHL_Algorithm/BasicFunctionByOrigin.cpp:107–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107pair<MatrixXd, vector<int>> getSubMatrix(const vector<int>& Sp, SparseQMatrix<double>& Ae) {
108 int size = Sp.size();
109 //cout << "size=" << size << endl;
110 //sort(Sp.begin(), Sp.end());
111 int cols = Ae.size;
112 MatrixXd subA(size, cols);
113 for (int i = 0; i < size; i++)
114 {
115 subA.row(i) = Ae.getSparseEigenRowVector(Sp[i]);
116 }
117
118 vector<int> NoZeroIndex;
119 for (int j = 0; j < cols; j++) {
120 VectorXd col_i = subA.col(j);
121 bool NoneZero = JudgeNoneZero(col_i);
122 if (NoneZero) {
123 NoZeroIndex.push_back(j);
124 }
125 }
126 int NoneZeroSize = NoZeroIndex.size();
127 MatrixXd No0subA(size, NoneZeroSize);
128 for (int i = 0; i < NoneZeroSize; i++) {
129 No0subA.col(i) = subA.col(NoZeroIndex[i]);
130 }
131 return make_pair(No0subA, NoZeroIndex);
132}
133
134
135VectorXd getb(int index, const vector<int>& No0Ind) {

Callers 1

Calls 6

JudgeNoneZeroFunction · 0.85
sizeMethod · 0.45
rowMethod · 0.45
colMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected