| 179 | } |
| 180 | |
| 181 | EigensystemResult pack_eigensystem_from_columns( |
| 182 | int n, |
| 183 | const std::vector<double>& eigenvalues, |
| 184 | const std::vector<std::vector<Complex>>& eigenvectors |
| 185 | ) { |
| 186 | const int n_roots = static_cast<int>(eigenvalues.size()); |
| 187 | if (static_cast<int>(eigenvectors.size()) != n_roots) { |
| 188 | throw std::invalid_argument("pack_eigensystem_from_columns: eigenvector count mismatch"); |
| 189 | } |
| 190 | EigensystemResult out; |
| 191 | out.n = n; |
| 192 | out.eigenvalues_ha = eigenvalues; |
| 193 | out.eigenvectors_col_major.assign( |
| 194 | static_cast<std::size_t>(n * n_roots), |
| 195 | Complex{0.0, 0.0} |
| 196 | ); |
| 197 | for (int root = 0; root < n_roots; ++root) { |
| 198 | const auto& col = eigenvectors[static_cast<std::size_t>(root)]; |
| 199 | if (static_cast<int>(col.size()) != n) { |
| 200 | throw std::invalid_argument("pack_eigensystem_from_columns: eigenvector length mismatch"); |
| 201 | } |
| 202 | for (int i = 0; i < n; ++i) { |
| 203 | out.eigenvectors_col_major[static_cast<std::size_t>(i + n * root)] = col[static_cast<std::size_t>(i)]; |
| 204 | } |
| 205 | } |
| 206 | return out; |
| 207 | } |
| 208 | |
| 209 | inline Complex& mat_ref(std::vector<Complex>& a, int n, int row, int col) { |
| 210 | return a[static_cast<std::size_t>(row + n * col)]; |
no test coverage detected