| 2417 | // type T can be CompMatr1, CompMatr2, CompMatr, DiagMatr1, DiagMatr2, DiagMatr, FullStateDiagMatr |
| 2418 | template <class T> |
| 2419 | void assertMatrixIsUnitary(T matr, const char* caller) { |
| 2420 | |
| 2421 | // validate both stack and heap matrices have been correctly initialised |
| 2422 | validate_matrixFields(matr, caller); |
| 2423 | |
| 2424 | // validate heap matrices have ever written to their GPU memories (if exists) |
| 2425 | if constexpr (util_isHeapMatrixType<T>()) |
| 2426 | validate_matrixIsSynced(matr, caller); |
| 2427 | |
| 2428 | // avoid superfluous expensive unitarity check below (do not overwrite .isApproxUnitary) |
| 2429 | if (isNumericalValidationDisabled()) |
| 2430 | return; |
| 2431 | |
| 2432 | // may overwrite matr.isApproxUnitary of heap matrices, otherwise ignores epsilon |
| 2433 | assertThat(util_isUnitary(matr, global_validationEpsilon), report::MATRIX_NOT_UNITARY, caller); |
| 2434 | } |
| 2435 | void validate_matrixIsUnitary(CompMatr1 m, const char* caller) { assertMatrixIsUnitary(m, caller); } |
| 2436 | void validate_matrixIsUnitary(CompMatr2 m, const char* caller) { assertMatrixIsUnitary(m, caller); } |
| 2437 | void validate_matrixIsUnitary(CompMatr m, const char* caller) { assertMatrixIsUnitary(m, caller); } |
no test coverage detected