|
18 | 18 |
|
19 | 19 | #include "Highs.h" |
20 | 20 | #include "io/HMPSIO.h" |
| 21 | +#include "utils.h" |
21 | 22 |
|
22 | 23 | constexpr size_t T_COORD = 2; |
23 | 24 |
|
@@ -51,24 +52,16 @@ SimplexDecoder::SimplexDecoder(SimplexConfig _config) : config(_config) { |
51 | 52 | dem_error_to_error = std::move(dem_error_map); |
52 | 53 | error_to_dem_error = common::invert_error_map(dem_error_to_error, config.dem.count_errors()); |
53 | 54 |
|
54 | | - std::vector<double> detector_t_coords(config.dem.count_detectors()); |
55 | | - for (const stim::DemInstruction& instruction : config.dem.flattened().instructions) { |
56 | | - switch (instruction.type) { |
57 | | - case stim::DemInstructionType::DEM_SHIFT_DETECTORS: |
58 | | - throw std::runtime_error("DEM_SHIFT_DETECTORS instruction is not supported."); |
59 | | - break; |
60 | | - case stim::DemInstructionType::DEM_ERROR: { |
61 | | - if (!(instruction.arg_data[0] > 0)) { |
62 | | - throw std::invalid_argument("Error instruction probability must be greater than zero."); |
63 | | - } |
64 | | - errors.emplace_back(instruction); |
65 | | - break; |
66 | | - } |
67 | | - case stim::DemInstructionType::DEM_DETECTOR: |
68 | | - detector_t_coords[instruction.target_data[0].val()] = instruction.arg_data[T_COORD]; |
69 | | - break; |
70 | | - default: |
71 | | - throw std::runtime_error("Unsupported instruction type encountered."); |
| 55 | + errors = get_errors_from_dem(config.dem.flattened()); |
| 56 | + |
| 57 | + std::vector<double> detector_t_coords(config.dem.count_detectors(), 0); |
| 58 | + std::vector<std::vector<double>> detector_coords = get_detector_coords(config.dem); |
| 59 | + if (detector_coords.size() != config.dem.count_detectors()) { |
| 60 | + throw std::runtime_error("Mismatch between detector coordinates and detector count."); |
| 61 | + } |
| 62 | + for (size_t d = 0; d < detector_coords.size(); ++d) { |
| 63 | + if (detector_coords[d].size() > T_COORD) { |
| 64 | + detector_t_coords[d] = detector_coords[d][T_COORD]; |
72 | 65 | } |
73 | 66 | } |
74 | 67 | std::map<double, std::vector<size_t>> start_time_to_errors_map, end_time_to_errors_map; |
|
0 commit comments