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

Function FastTransfer2SparseQMat

Applications/HHL_Algorithm/SparseQMatrix.h:460–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458
459template<class Ty>
460void FastTransfer2SparseQMat(vector<pair<int, Ty>>* sparse_data, int size, SparseQMatrix<Ty>& M) {
461
462 int nnz_num = 0;
463 M.SetRowNum(size);
464 M.nnzcol_ptr[0] = 0;
465 for (int i = 0; i < size; i++) {
466 nnz_num += sparse_data[i].size();
467 M.nnzcol_ptr[i + 1] = nnz_num;
468 }
469 auto nnz = nnz_num;
470 M.SetNNZ(nnz);
471#pragma omp parallel for
472 for (int i = 0; i < size; i++) {
473 for (int j = 0; j < sparse_data[i].size(); j++) {
474 M.data[M.nnzcol_ptr[i] + j] = sparse_data[i][j].second;
475 M.nnzcol_ind[M.nnzcol_ptr[i] + j] = sparse_data[i][j].first;
476 }
477 }
478}
479
480template<class Ty>
481void FastTransfer2SparseQMat(vector<vector<pair<Ty, size_t>>>& sparse_data, SparseQMatrix<Ty>& M) {

Callers 4

MprodcutAFunction · 0.85

Calls 3

SetRowNumMethod · 0.80
sizeMethod · 0.45
SetNNZMethod · 0.45

Tested by

no test coverage detected