| 1199 | // T can be any 1D type, e.g. Qureg (.isDensityMatrix=0), FullStateDiagMatr, DiagMatr/1/2 |
| 1200 | template <class T> |
| 1201 | void printVector(T obj, string indent) { |
| 1202 | |
| 1203 | // divide vector into one of two column vectors (ul and ll; ur and lr stay empty) |
| 1204 | qcompmatr ul,ur,ll,lr; |
| 1205 | qindex numAmps = powerOf2(obj.numQubits); |
| 1206 | MatrixQuadrantInds inds = getTruncatedMatrixQuadrantInds(numAmps, 1); |
| 1207 | allocateMatrixQuadrants(inds, ul,ur,ll,lr); |
| 1208 | populateMatrixQuadrants(inds, ul,ur,ll,lr, obj); |
| 1209 | |
| 1210 | // rows are only labelled if we're printing a Qureg... |
| 1211 | vector<string> upperRowLabels = {}; |
| 1212 | vector<string> lowerRowLabels = {}; |
| 1213 | if constexpr (util_isQuregType<T>()) { |
| 1214 | upperRowLabels = getBasisKets(inds.upperStartRow, inds.numUpperLeftRows); |
| 1215 | lowerRowLabels = getBasisKets(inds.lowerStartRow, inds.numLowerLeftRows); |
| 1216 | } |
| 1217 | |
| 1218 | // and/or if the type is distributed |
| 1219 | if constexpr (util_isDistributableType<T>()) |
| 1220 | if (obj.isDistributed) |
| 1221 | populateDistributedVectorRowLabels(upperRowLabels, lowerRowLabels, obj, inds); |
| 1222 | |
| 1223 | // columns are never labelled |
| 1224 | vector<string> colLabels = {}; |
| 1225 | |
| 1226 | // only successively indent each row when vector represets a diagonal matrix |
| 1227 | bool indentEachRow = ! util_isQuregType<T>(); // since else diagonal |
| 1228 | string indentPerRow = (indentEachRow)? string(SET_SPACE_BETWEEN_DIAG_MATRIX_COLS, MATRIX_SPACE_CHAR) : ""; |
| 1229 | string ellipsisChar = (indentEachRow)? DDOTS_CHAR : VDOTS_CHAR; |
| 1230 | |
| 1231 | // will print the vector in one or two quadrants (right two quadrants are unpopulated) |
| 1232 | printMatrixInFourQuadrants( |
| 1233 | ul, ur, ll, lr, |
| 1234 | colLabels, colLabels, upperRowLabels, lowerRowLabels, |
| 1235 | indent, indentPerRow, ellipsisChar); |
| 1236 | } |
| 1237 | |
| 1238 | |
| 1239 | void print_elems(DiagMatr1 obj, string indent) { printVector(obj, indent); } |
no test coverage detected