| 1072 | // importantly, it excludes KrausMap which is handled separately |
| 1073 | template <class T> |
| 1074 | void printDenseSquareMatrix(T obj, string indent) { |
| 1075 | |
| 1076 | // determine the full matrix dimension |
| 1077 | qindex numRows; |
| 1078 | if constexpr (util_isDenseMatrixType<T>()) |
| 1079 | numRows = obj.numRows; |
| 1080 | else |
| 1081 | numRows = powerOf2(obj.numQubits); // this would be wrong for SuperOp |
| 1082 | |
| 1083 | // work out which global amps are going to be printed, divided into quadrants |
| 1084 | MatrixQuadrantInds inds = getTruncatedMatrixQuadrantInds(numRows, numRows); |
| 1085 | |
| 1086 | // populate quadrants (which may involve a GPU to CPU copy and/or communication) |
| 1087 | qcompmatr ul,ur,ll,lr; |
| 1088 | allocateMatrixQuadrants(inds, ul,ur,ll,lr); |
| 1089 | populateMatrixQuadrants(inds, ul,ur,ll,lr, obj); |
| 1090 | |
| 1091 | // columns are only labelled if given a distributed Qureg (they become sender node) |
| 1092 | vector<string> leftColLabels, rightColLabels; |
| 1093 | if constexpr (util_isQuregType<T>()) |
| 1094 | if (obj.isDistributed) |
| 1095 | populateDensityMatrixColumnLabels(leftColLabels, rightColLabels, obj, inds); |
| 1096 | |
| 1097 | // do not label rows nor successively indent them |
| 1098 | vector<string> rowLabels = {}; |
| 1099 | string indentPerRow = ""; |
| 1100 | |
| 1101 | printMatrixInFourQuadrants( |
| 1102 | ul, ur, ll, lr, |
| 1103 | leftColLabels, rightColLabels, rowLabels, rowLabels, |
| 1104 | indent, indentPerRow, VDOTS_CHAR); |
| 1105 | } |
| 1106 | |
| 1107 | |
| 1108 | void print_elems(CompMatr1 obj, string indent) { printDenseSquareMatrix(obj, indent); } |
no test coverage detected