| 97 | } |
| 98 | |
| 99 | std::vector<Complex> dense_matvec( |
| 100 | const std::vector<Complex>& h_col_major, |
| 101 | int n, |
| 102 | const std::vector<Complex>& x |
| 103 | ) { |
| 104 | if (x.size() != static_cast<std::size_t>(n)) { |
| 105 | throw std::invalid_argument("dense_matvec: vector size mismatch"); |
| 106 | } |
| 107 | std::vector<Complex> y(static_cast<std::size_t>(n), Complex{0.0, 0.0}); |
| 108 | for (int row = 0; row < n; ++row) { |
| 109 | Complex sum{0.0, 0.0}; |
| 110 | for (int col = 0; col < n; ++col) { |
| 111 | sum += h_col_major[static_cast<std::size_t>(row + n * col)] * x[static_cast<std::size_t>(col)]; |
| 112 | } |
| 113 | y[static_cast<std::size_t>(row)] = sum; |
| 114 | } |
| 115 | return y; |
| 116 | } |
| 117 | |
| 118 | std::vector<std::vector<Complex>> apply_h_to_basis( |
| 119 | const std::vector<Complex>& h_col_major, |
no test coverage detected