-
Notifications
You must be signed in to change notification settings - Fork 69
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
A function to compute the downsampling error #1613
Conversation
6407b92
to
322e3c3
Compare
geometry/named_quantities.hpp
Outdated
struct Normed : base::not_constructible { | ||
using NormType = T; | ||
static NormType Norm(T const& vector) { | ||
return quantities::Abs(vector); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/named_quantities.hpp
Outdated
: base::not_constructible { | ||
using NormType = decltype(std::declval<T>().Norm()); | ||
static NormType Norm(T const& vector) { | ||
return vector.Norm(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
numerics/hermite3_body.hpp
Outdated
typename Normed<Difference<Value>>::NormType | ||
Hermite3<Argument, Value>::LInfinityError(Samples const& samples, | ||
GetArgument get_argument, | ||
GetValue get_value) const { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterating on double :-O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
¯\_(ツ)_/¯
numerics/hermite3_test.cpp
Outdated
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent += 4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
numerics/hermite3_test.cpp
Outdated
EXPECT_THAT( | ||
not_a_quartic.LInfinityError( | ||
samples, | ||
/*get_argument=*/[](auto&& pair) -> auto&& { return pair.first; }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad indent (2x).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
numerics/hermite3_test.cpp
Outdated
/*get_value=*/[](auto&& pair) -> auto&& { return pair.second; }), | ||
AllOf(Gt(1 * Centi(Metre)), Lt(2 * Centi(Metre)))); | ||
} | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
This is part of the work on #228. |
Doing it in numerics, so fairly heavy templatization.