Skip to content

A function to compute the downsampling error #1613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 31, 2017

Conversation

eggrobin
Copy link
Member

Doing it in numerics, so fairly heavy templatization.

@eggrobin eggrobin force-pushed the downsampling-algorithm branch from 6407b92 to 322e3c3 Compare October 22, 2017 20:15
struct Normed : base::not_constructible {
using NormType = T;
static NormType Norm(T const& vector) {
return quantities::Abs(vector);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the method implementations to the body file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know to write the definitions out of line with this fancy specialization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

: base::not_constructible {
using NormType = decltype(std::declval<T>().Norm());
static NormType Norm(T const& vector) {
return vector.Norm();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// Returns the largest error (in the given |norm|) between this polynomial and
// the given |samples|.
template<typename Samples, typename GetArgument, typename GetValue>
typename Normed<Difference<Value>>::NormType LInfinityError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the infinity symbol work in an identifier?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we had the same issue with InfinitePast and InfiniteFuture.

typename Normed<Difference<Value>>::NormType
Hermite3<Argument, Value>::LInfinityError(Samples const& samples,
GetArgument get_argument,
GetValue get_value) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass the functors by reference, you are not moving them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -82,5 +95,50 @@ TEST_F(Hermite3Test, Conditioning) {
h.EvaluateDerivative(t0_ + 19418861.806896236 * Second));
}

TEST_F(Hermite3Test, OneDimensionalInterpolationError) {
std::vector<std::pair<double, double>> samples;
for (double i = 2; i < 10; i += 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterating on double :-O

Copy link
Member Author

@eggrobin eggrobin Oct 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯\_(ツ)_/¯

AngularFrequency const ω = 1 * Radian / Second;
for (Instant t = t0_; t <= tmax; t += 1 / 32.0 * Second) {
samples.push_back(
{t, World::origin + Displacement<World>({Cos(ω * (t - t0_)) * Metre,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent += 4

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

EXPECT_THAT(
not_a_quartic.LInfinityError(
samples,
/*get_argument=*/[](auto&& pair) -> auto&& { return pair.first; },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad indent (2x).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/*get_value=*/[](auto&& pair) -> auto&& { return pair.second; }),
AllOf(Gt(1 * Centi(Metre)), Lt(2 * Centi(Metre))));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a test with a quartic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do (it's the one above), but perhaps I shouldn't call the function that tries to match a circle not_a_quartic... :-p

@eggrobin eggrobin merged commit ce300c4 into mockingbirdnest:master Oct 31, 2017
@eggrobin
Copy link
Member Author

eggrobin commented Nov 6, 2017

This is part of the work on #228.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants