Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 30269df36353
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 98091a23c570
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Jul 4, 2021

  1. Interrupt FitHermiteSpline

    eggrobin committed Jul 4, 2021
    Copy the full SHA
    8826d9e View commit details
  2. propagate

    eggrobin committed Jul 4, 2021
    Copy the full SHA
    91ae856 View commit details
  3. .value()

    eggrobin committed Jul 4, 2021
    Copy the full SHA
    19de20c View commit details
  4. Merge pull request #3042 from eggrobin/3033

    Make FitHermiteSpline interruptible
    eggrobin authored Jul 4, 2021
    Copy the full SHA
    98091a2 View commit details
3 changes: 2 additions & 1 deletion numerics/fit_hermite_spline.hpp
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

#include <list>

#include "absl/status/statusor.h"
#include "geometry/hilbert.hpp"
#include "numerics/hermite3.hpp"

@@ -25,7 +26,7 @@ using geometry::Hilbert;
// that the |Hermite3| interpolation of (*itᵣ, *(samples.end() - 1)) fits
// |samples| within |tolerance|.
template<typename Argument, typename Value, typename Samples>
std::list<typename Samples::const_iterator> FitHermiteSpline(
absl::StatusOr<std::list<typename Samples::const_iterator>> FitHermiteSpline(
Samples const& samples,
std::function<Argument const&(typename Samples::value_type const&)> const&
get_argument,
4 changes: 3 additions & 1 deletion numerics/fit_hermite_spline_body.hpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
#include <list>
#include <type_traits>

#include "base/jthread.hpp"
#include "base/ranges.hpp"
#include "numerics/hermite3.hpp"

@@ -14,7 +15,7 @@ namespace internal_fit_hermite_spline {
using base::Range;

template<typename Argument, typename Value, typename Samples>
std::list<typename Samples::const_iterator> FitHermiteSpline(
absl::StatusOr<std::list<typename Samples::const_iterator>> FitHermiteSpline(
Samples const& samples,
std::function<Argument const&(typename Samples::value_type const&)> const&
get_argument,
@@ -57,6 +58,7 @@ std::list<typename Samples::const_iterator> FitHermiteSpline(
Iterator lower = begin + 1;
Iterator upper = last;
for (;;) {
RETURN_IF_STOPPED;
auto const middle = lower + (upper - lower) / 2;
// Note that lower ≤ middle ≤ upper.
// If middle - lower > 0, upper - lower > 0,
2 changes: 1 addition & 1 deletion numerics/fit_hermite_spline_test.cpp
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ TEST_F(FitHermiteSplineTest, Sinusoid) {
[](auto&& sample) -> auto&& { return sample.t; },
[](auto&& sample) -> auto&& { return sample.x; },
[](auto&& sample) -> auto&& { return sample.v; },
1 * Centi(Metre));
1 * Centi(Metre)).value();

// Note that gmock doesn't do decltypes, so we can't pass a λ directly.
// Also note that |Pointee| doesn't work with iterators, so
5 changes: 3 additions & 2 deletions physics/discrete_trajectory.hpp
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
#include <optional>
#include <vector>

#include "absl/status/status.h"
#include "base/not_constructible.hpp"
#include "base/not_null.hpp"
#include "geometry/grassmann.hpp"
@@ -121,8 +122,8 @@ class DiscreteTrajectory : public Forkable<DiscreteTrajectory<Frame>,
not_null<std::unique_ptr<DiscreteTrajectory<Frame>>> DetachFork();

// Appends one point to the trajectory.
void Append(Instant const& time,
DegreesOfFreedom<Frame> const& degrees_of_freedom);
absl::Status Append(Instant const& time,
DegreesOfFreedom<Frame> const& degrees_of_freedom);

// Removes all data for times (strictly) greater than |time|, as well as all
// child trajectories forked at times (strictly) greater than |time|. |time|
16 changes: 11 additions & 5 deletions physics/discrete_trajectory_body.hpp
Original file line number Diff line number Diff line change
@@ -181,7 +181,7 @@ DiscreteTrajectory<Frame>::DetachFork() {
}

template<typename Frame>
void DiscreteTrajectory<Frame>::Append(
absl::Status DiscreteTrajectory<Frame>::Append(
Instant const& time,
DegreesOfFreedom<Frame> const& degrees_of_freedom) {
CHECK(this->is_root() || time > this->Fork()->time)
@@ -192,7 +192,7 @@ void DiscreteTrajectory<Frame>::Append(
LOG(WARNING) << "Append at existing time " << time
<< ", time range = [" << this->front().time << ", "
<< this->back().time << "]";
return;
return absl::OkStatus();
}
auto it = timeline_.emplace_hint(timeline_.end(),
time,
@@ -223,11 +223,16 @@ void DiscreteTrajectory<Frame>::Append(
[](auto&& it) -> auto&& { return it->second.position(); },
[](auto&& it) -> auto&& { return it->second.velocity(); },
downsampling_->tolerance());
if (right_endpoints.empty()) {
right_endpoints.push_back(dense_iterators.end() - 1);
if (!right_endpoints.ok()) {
// Note that the actual appending took place; the propagated status
// only reflects a lack of downsampling.
return right_endpoints.status();
}
if (right_endpoints->empty()) {
right_endpoints->push_back(dense_iterators.end() - 1);
}
TimelineConstIterator left = downsampling_->start_of_dense_timeline();
for (const auto& it_in_dense_iterators : right_endpoints) {
for (const auto& it_in_dense_iterators : right_endpoints.value()) {
TimelineConstIterator const right = *it_in_dense_iterators;
timeline_.erase(++left, right);
left = right;
@@ -236,6 +241,7 @@ void DiscreteTrajectory<Frame>::Append(
}
}
}
return absl::OkStatus();
}

template<typename Frame>