| 521 | |
| 522 | |
| 523 | qmatrix getKroneckerProduct(qmatrix a, qmatrix b) { |
| 524 | |
| 525 | // we permit the matrices to be non-square which is |
| 526 | // pretty cheeky (since qmatrix is assumed square with |
| 527 | // a 2^N dimension by most other functions), but is |
| 528 | // necessary for us to compute partial traces |
| 529 | |
| 530 | size_t aRows = a.size(); |
| 531 | size_t bRows = b.size(); |
| 532 | size_t aCols = a[0].size(); |
| 533 | size_t bCols = b[0].size(); |
| 534 | |
| 535 | qmatrix out(aRows * bRows, qvector(aCols * bCols)); |
| 536 | |
| 537 | for (size_t r=0; r<bRows; r++) |
| 538 | for (size_t c=0; c<bCols; c++) |
| 539 | for (size_t i=0; i<aRows; i++) |
| 540 | for (size_t j=0; j<aCols; j++) |
| 541 | out[r+bRows*i][c+bCols*j] = a[i][j] * b[r][c]; |
| 542 | |
| 543 | return out; |
| 544 | } |
| 545 | |
| 546 | |
| 547 | qmatrix getKroneckerProduct(vector<qmatrix> matrices) { |
no test coverage detected