diff --git a/CMakeLists.txt b/CMakeLists.txt index bef1c6b7..ebe53013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,5 +219,3 @@ add_custom_command(TARGET regression_tests PRE_BUILD ${RTESTS_DATA} regression_test_data/old_data/.) add_custom_command(TARGET regression_tests POST_BUILD COMMAND regression_tests COMMENT "Running regression tests") - - diff --git a/src/sydevs/core/arraynd.h b/src/sydevs/core/arraynd.h index 3703c23c..b351295b 100644 --- a/src/sydevs/core/arraynd.h +++ b/src/sydevs/core/arraynd.h @@ -1164,20 +1164,30 @@ std::ostream& operator<<(std::ostream& os, const arraynd& rhs) os << "{"; while (idim >= 0) { if (indices[idim] < rhs.dims()[idim]) { + // The index is not beyond the last element on the current axis. + // Continue outputting the current sub-array. if (indices[idim] > 0) { + // This is not the first element on the current axis. + // Output a delimiter. os << ", "; } if (idim == ndims - 1) { + // The current axis is the last one. + // Output the current element and advance the index. os << rhs.data()[offset]; ++indices[idim]; offset += rhs.strides()[idim]; } else { + // The current axis is not the last one. + // Start outputting a new sub-array. ++idim; os << "{"; } } else { + // The index is beyond the last element on the current axis. + // Finish outputting the current sub-array. indices[idim] = 0; offset -= rhs.dims()[idim]*rhs.strides()[idim]; --idim; diff --git a/src/sydevs/systems/simulation.h b/src/sydevs/systems/simulation.h index f42077ea..9a478837 100644 --- a/src/sydevs/systems/simulation.h +++ b/src/sydevs/systems/simulation.h @@ -406,17 +406,21 @@ inline void simulation::advance_time() if (!finishing_) { auto planned_dt = t_queue_.imminent_duration(); if (planned_dt.finite() || !can_end_early_) { + // The event time must advance. event_time().advance(planned_dt, end_t_); if (planned_dt > 0_s) { + // The simulated time just advanced. external_context_.time_printed() = false; t_queue_.advance_time(event_time().t()); t_cache_.advance_time(event_time().t()); } if (event_time().t() >= end_t_) { + // The end time has been reached. finishing_ = true; } } else { + // The simulation must finish at the current event time. finishing_ = true; } }