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

Function precondition

Applications/HHL_Algorithm/preconditionByOrigin.cpp:316–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314
315
316void precondition(SparseQMatrix<double>& M, SparseQMatrix<double>& A, vector<double>& b,
317 int KindLinPrec, int SparseIndex, double DySPepsilon) {
318 auto dim = M.size;
319 vector<vector<double>> diagD;
320 vector<double> d1;
321 //vector<double> d2;
322 SparseQMatrix<double> Ms;
323
324 switch (KindLinPrec) {
325 case NO_PRE:
326 A = M;
327 break;
328 case DIAGNOAL_SCALING:
329 DiagonalScalingNew(M, diagD);
330 cout << "DiagonalScaling is over" << endl;
331 d1 = diagD[0];
332 dright = diagD[1];
333 A = M;
334 for (int i = 0; i < dim; i++) {
335 b[i] = b[i] * d1[i];
336 }
337 break;
338 case STATIC_SPAI:
339 Ms = StaticSparseApproximateInverse(M, SparseIndex);
340 cout << "Static Sparse Approximate Inverse is over" << endl;
341 A = MprodcutA(Ms, M, SparseIndex);
342 b = MproductbDen(Ms, b);
343 break;
344 case DYNAMIC_SPAI:
345 A = DynamicSparseApproximateInverse(M, Ms, DySPepsilon, SparseIndex);
346 cout << "Dynamic Sparse Approximate Inverse is over" << endl;
347 b = MproductbDen(Ms, b);
348 break;
349 case POWER_SAI_LEFT:
350 A = PowerSparseApproximateInverseLeft(M, Ms, DySPepsilon, SparseIndex);
351 cout << "Power Sparse Approximate Inverse is over" << endl;
352 b = MproductbDen(Ms, b);
353 break;
354 case JACOBI_P:
355 A = JacobiPrecondition(M, b);
356 break;
357 }
358}
359
360std::pair< Eigen::MatrixXd, Eigen::VectorXd > DynamicSparseApproximateInverse(Eigen::MatrixXd& Ae, Eigen::VectorXd& b, double epsilon, int SparseIndex, Eigen::MatrixXd& M) {
361 //sparI = read_sparsity();

Callers

nothing calls this directly

Calls 7

DiagonalScalingNewFunction · 0.85
MprodcutAFunction · 0.85
MproductbDenFunction · 0.85
JacobiPreconditionFunction · 0.85

Tested by

no test coverage detected