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: ea6fc2af69a0
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8135436f32d6
Choose a head ref
  • 4 commits
  • 16 files changed
  • 1 contributor

Commits on Aug 29, 2020

  1. Remove Normed.

    pleroy committed Aug 29, 2020
    Copy the full SHA
    2d35691 View commit details
  2. Use is_quantity_v.

    pleroy committed Aug 29, 2020
    Copy the full SHA
    e69ece2 View commit details
  3. A compilation error.

    pleroy committed Aug 29, 2020
    Copy the full SHA
    2d2e02f View commit details
  4. Merge pull request #2698 from pleroy/UseHilbert

    Remove Normed and use Hilbert everywhere
    pleroy authored Aug 29, 2020
    Copy the full SHA
    8135436 View commit details
1 change: 0 additions & 1 deletion geometry/geometry.vcxproj
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
<ClInclude Include="interval_body.hpp" />
<ClInclude Include="linear_map_body.hpp" />
<ClInclude Include="named_quantities.hpp" />
<ClInclude Include="named_quantities_body.hpp" />
<ClInclude Include="pair.hpp" />
<ClInclude Include="pair_body.hpp" />
<ClInclude Include="perspective.hpp" />
3 changes: 0 additions & 3 deletions geometry/geometry.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -131,9 +131,6 @@
<ClInclude Include="sphere_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="named_quantities_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="symmetric_bilinear_form.hpp">
<Filter>Header Files</Filter>
</ClInclude>
8 changes: 4 additions & 4 deletions geometry/grassmann.hpp
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ namespace internal_grassmann {

using base::not_null;
using quantities::Angle;
using quantities::is_quantity;
using quantities::is_quantity_v;
using quantities::Product;
using quantities::Quantity;
using quantities::Quotient;
@@ -265,19 +265,19 @@ Multivector<Scalar, Frame, rank> operator-(
Multivector<Scalar, Frame, rank> const& right);

template<typename LScalar, typename RScalar, typename Frame, int rank,
typename = std::enable_if_t<is_quantity<LScalar>::value>>
typename = std::enable_if_t<is_quantity_v<LScalar>>>
Multivector<Product<LScalar, RScalar>, Frame, rank>
operator*(LScalar const& left,
Multivector<RScalar, Frame, rank> const& right);

template<typename LScalar, typename RScalar, typename Frame, int rank,
typename = std::enable_if_t<is_quantity<RScalar>::value>>
typename = std::enable_if_t<is_quantity_v<RScalar>>>
Multivector<Product<LScalar, RScalar>, Frame, rank>
operator*(Multivector<LScalar, Frame, rank> const& left,
RScalar const& right);

template<typename LScalar, typename RScalar, typename Frame, int rank,
typename = std::enable_if_t<is_quantity<RScalar>::value>>
typename = std::enable_if_t<is_quantity_v<RScalar>>>
Multivector<Quotient<LScalar, RScalar>, Frame, rank>
operator/(Multivector<LScalar, Frame, rank> const& left,
RScalar const& right);
18 changes: 0 additions & 18 deletions geometry/named_quantities.hpp
Original file line number Diff line number Diff line change
@@ -13,22 +13,6 @@
namespace principia {
namespace geometry {

// A trait to treat types that have a norm uniformly (using Abs for quantities
// or double, and Norm for multivectors).
template<typename T,
typename = std::void_t<decltype(quantities::Abs(std::declval<T>()))>>
struct Normed : base::not_constructible {
using NormType = T;
static NormType Norm(T const& vector);
};

template<typename T>
struct Normed<T, std::void_t<decltype(std::declval<T>().Norm())>>
: base::not_constructible {
using NormType = decltype(std::declval<T>().Norm());
static NormType Norm(T const& vector);
};

using Instant = Point<quantities::Time>;
template<typename Frame>
using Displacement = Vector<quantities::Length, Frame>;
@@ -52,5 +36,3 @@ using InertiaTensor =

} // namespace geometry
} // namespace principia

#include "geometry/named_quantities_body.hpp"
22 changes: 0 additions & 22 deletions geometry/named_quantities_body.hpp

This file was deleted.

18 changes: 9 additions & 9 deletions geometry/point.hpp
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ namespace geometry {
namespace internal_point {

using base::not_null;
using quantities::is_quantity;
using quantities::is_quantity_v;

// Point<Vector> is an affine space on the vector space Vector. Vector should
// be equipped with operators +, -, +=, -=, ==, !=, as well as Vector * Weight
@@ -65,16 +65,16 @@ class Point final {
friend Point<V> operator+(V const& translation, Point<V> const& point);

template<typename V>
friend constexpr typename std::enable_if_t<is_quantity<V>::value, bool>
friend constexpr typename std::enable_if_t<is_quantity_v<V>, bool>
operator<(Point<V> const& left, Point<V> const& right);
template<typename V>
friend constexpr typename std::enable_if_t<is_quantity<V>::value, bool>
friend constexpr typename std::enable_if_t<is_quantity_v<V>, bool>
operator<=(Point<V> const& left, Point<V> const& right);
template<typename V>
friend constexpr typename std::enable_if_t<is_quantity<V>::value, bool>
friend constexpr typename std::enable_if_t<is_quantity_v<V>, bool>
operator>=(Point<V> const& left, Point<V> const& right);
template<typename V>
friend constexpr typename std::enable_if_t<is_quantity<V>::value, bool>
friend constexpr typename std::enable_if_t<is_quantity_v<V>, bool>
operator>(Point<V> const& left, Point<V> const& right);

template<typename V>
@@ -90,19 +90,19 @@ Point<Vector> operator+(Vector const& translation,
Point<Vector> const& point);

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool>
operator<(Point<Vector> const& left, Point<Vector> const& right);

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool>
operator<=(Point<Vector> const& left, Point<Vector> const& right);

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool>
operator>=(Point<Vector> const& left, Point<Vector> const& right);

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool>
operator>(Point<Vector> const& left, Point<Vector> const& right);

template<typename Vector>
8 changes: 4 additions & 4 deletions geometry/point_body.hpp
Original file line number Diff line number Diff line change
@@ -129,26 +129,26 @@ Point<Vector> operator+(Vector const& translation,
}

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool> operator<(
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool> operator<(
Point<Vector> const& left,
Point<Vector> const& right) {
return left.coordinates_ < right.coordinates_;
}

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool>
operator<=(Point<Vector> const& left, Point<Vector> const& right) {
return left.coordinates_ <= right.coordinates_;
}

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool>
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool>
operator>=(Point<Vector> const& left, Point<Vector> const& right) {
return left.coordinates_ >= right.coordinates_;
}

template<typename Vector>
constexpr typename std::enable_if_t<is_quantity<Vector>::value, bool> operator>(
constexpr typename std::enable_if_t<is_quantity_v<Vector>, bool> operator>(
Point<Vector> const& left,
Point<Vector> const& right) {
return left.coordinates_ > right.coordinates_;
2 changes: 1 addition & 1 deletion geometry/point_test.cpp
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ TEST_F(PointTest, AssignmentOperators) {
}

TEST_F(PointTest, Ordering) {
// Check that is_quantity works for double.
// Check that is_quantity_v works for double.
Point<double> zero;
Point<double> d1 = zero + 1.0;
Point<double> d2 = zero -3.0;
8 changes: 4 additions & 4 deletions geometry/r3_element.hpp
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ namespace internal_r3_element {
using base::not_null;
using base::uninitialized_t;
using quantities::Angle;
using quantities::is_quantity;
using quantities::is_quantity_v;
using quantities::Product;
using quantities::Quantity;
using quantities::Quotient;
@@ -114,17 +114,17 @@ R3Element<Scalar> operator-(R3Element<Scalar> const& left,
// The special case where one of the scalars is |double| is handled separately
// above in order to allow implicit conversions to |double|.
template<typename LScalar, typename RScalar,
typename = std::enable_if_t<is_quantity<LScalar>::value>>
typename = std::enable_if_t<is_quantity_v<LScalar>>>
R3Element<Product<LScalar, RScalar>>
operator*(LScalar const& left, R3Element<RScalar> const& right);

template<typename LScalar, typename RScalar,
typename = std::enable_if_t<is_quantity<RScalar>::value>>
typename = std::enable_if_t<is_quantity_v<RScalar>>>
R3Element<Product<LScalar, RScalar>>
operator*(R3Element<LScalar> const& left, RScalar const& right);

template<typename LScalar, typename RScalar,
typename = std::enable_if_t<is_quantity<RScalar>::value>>
typename = std::enable_if_t<is_quantity_v<RScalar>>>
R3Element<Quotient<LScalar, RScalar>>
operator/(R3Element<LScalar> const& left, RScalar const& right);

8 changes: 4 additions & 4 deletions geometry/r3x3_matrix.hpp
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ namespace internal_r3x3_matrix {
using base::not_null;
using base::uninitialized_t;
using quantities::Cube;
using quantities::is_quantity;
using quantities::is_quantity_v;
using quantities::Product;
using quantities::Quotient;

@@ -152,17 +152,17 @@ R3Element<Product<LScalar, RScalar>> operator*(
R3x3Matrix<RScalar> const& right);

template<typename LScalar, typename RScalar,
typename = std::enable_if_t<is_quantity<LScalar>::value>>
typename = std::enable_if_t<is_quantity_v<LScalar>>>
R3x3Matrix<Product<LScalar, RScalar>> operator*(
LScalar const& left,
R3x3Matrix<RScalar> const& right);
template<typename LScalar, typename RScalar,
typename = std::enable_if_t<is_quantity<LScalar>::value>>
typename = std::enable_if_t<is_quantity_v<LScalar>>>
R3x3Matrix<Product<LScalar, RScalar>> operator*(
R3x3Matrix<LScalar> const& left,
RScalar const& right);
template<typename LScalar, typename RScalar,
typename = std::enable_if_t<is_quantity<LScalar>::value>>
typename = std::enable_if_t<is_quantity_v<LScalar>>>
R3x3Matrix<Quotient<LScalar, RScalar>> operator/(
R3x3Matrix<LScalar> const& left,
RScalar const& right);
5 changes: 3 additions & 2 deletions numerics/fit_hermite_spline.hpp
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

#include <list>

#include "geometry/hilbert.hpp"
#include "numerics/hermite3.hpp"

namespace principia {
@@ -10,7 +11,7 @@ namespace internal_fit_hermite_spline {

using quantities::Derivative;
using quantities::Difference;
using geometry::Normed;
using geometry::Hilbert;

// Given |samples| for which the arguments, values, and derivatives can be
// obtained via the given functors, returns a sequence of iterators
@@ -32,7 +33,7 @@ std::list<typename Samples::const_iterator> FitHermiteSpline(
get_value,
std::function<Derivative<Value, Argument> const&(
typename Samples::value_type const&)> const& get_derivative,
typename Normed<Difference<Value>>::NormType const& tolerance);
typename Hilbert<Difference<Value>>::NormType const& tolerance);

} // namespace internal_fit_hermite_spline

3 changes: 1 addition & 2 deletions numerics/fit_hermite_spline_body.hpp
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ namespace numerics {
namespace internal_fit_hermite_spline {

using base::Range;
using geometry::Normed;

template<typename Argument, typename Value, typename Samples>
std::list<typename Samples::const_iterator> FitHermiteSpline(
@@ -23,7 +22,7 @@ std::list<typename Samples::const_iterator> FitHermiteSpline(
get_value,
std::function<Derivative<Value, Argument> const&(
typename Samples::value_type const&)> const& get_derivative,
typename Normed<Difference<Value>>::NormType const& tolerance) {
typename Hilbert<Difference<Value>>::NormType const& tolerance) {
using Iterator = typename Samples::const_iterator;

auto interpolation_error = [get_argument, get_derivative, get_value](
1 change: 1 addition & 0 deletions numerics/fit_hermite_spline_test.cpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
#include <list>
#include <vector>

#include "geometry/named_quantities.hpp"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "numerics/double_precision.hpp"
6 changes: 3 additions & 3 deletions numerics/hermite3.hpp
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
#include <vector>

#include "base/array.hpp"
#include "geometry/named_quantities.hpp"
#include "geometry/hilbert.hpp"
#include "quantities/named_quantities.hpp"

namespace principia {
@@ -16,7 +16,7 @@ namespace internal_hermite3 {
using base::BoundedArray;
using quantities::Derivative;
using quantities::Difference;
using geometry::Normed;
using geometry::Hilbert;

// A 3rd degree Hermite polynomial defined by its values and derivatives at the
// bounds of some interval.
@@ -44,7 +44,7 @@ class Hermite3 final {
// Returns the largest error (in the given |norm|) between this polynomial and
// the given |samples|.
template<typename Samples>
typename Normed<Difference<Value>>::NormType LInfinityError(
typename Hilbert<Difference<Value>>::NormType LInfinityError(
Samples const& samples,
std::function<Argument const&(typename Samples::value_type const&)> const&
get_argument,
6 changes: 3 additions & 3 deletions numerics/hermite3_body.hpp
Original file line number Diff line number Diff line change
@@ -66,17 +66,17 @@ BoundedArray<Argument, 2> Hermite3<Argument, Value>::FindExtrema() const {

template<typename Argument, typename Value>
template<typename Samples>
typename Normed<Difference<Value>>::NormType
typename Hilbert<Difference<Value>>::NormType
Hermite3<Argument, Value>::LInfinityError(
Samples const& samples,
std::function<Argument const&(
typename Samples::value_type const&)> const& get_argument,
std::function<Value const&(typename Samples::value_type const&)> const&
get_value) const {
typename Normed<Difference<Value>>::NormType result{};
typename Hilbert<Difference<Value>>::NormType result{};
for (const auto& sample : samples) {
result = std::max(result,
Normed<Difference<Value>>::Norm(
Hilbert<Difference<Value>>::Norm(
Evaluate(get_argument(sample)) - get_value(sample)));
}
return result;
15 changes: 8 additions & 7 deletions numerics/pid.hpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
#include <deque>
#include <optional>

#include "geometry/hilbert.hpp"
#include "geometry/named_quantities.hpp"
#include "quantities/named_quantities.hpp"
#include "quantities/quantities.hpp"
@@ -12,8 +13,8 @@ namespace principia {
namespace numerics {
namespace internal_pid {

using geometry::Hilbert;
using geometry::Instant;
using geometry::Normed;
using quantities::Difference;
using quantities::Product;
using quantities::Quotient;
@@ -28,13 +29,13 @@ class PID {
public:
static_assert(finite_difference_order <= horizon);

using Kp = Quotient<typename Normed<Output>::NormType,
typename Normed<Difference<Input>>::NormType>;
using Ki = Quotient<typename Normed<Output>::NormType,
typename Normed<Product<Difference<Input>, Time>>::
using Kp = Quotient<typename Hilbert<Output>::NormType,
typename Hilbert<Difference<Input>>::NormType>;
using Ki = Quotient<typename Hilbert<Output>::NormType,
typename Hilbert<Product<Difference<Input>, Time>>::
NormType>;
using Kd = Quotient<typename Normed<Output>::NormType,
typename Normed<Difference<Variation<Input>>>::NormType>;
using Kd = Quotient<typename Hilbert<Output>::NormType,
typename Hilbert<Difference<Variation<Input>>>::NormType>;

PID(Kp const& kp, Ki const& ki, Kd const& kd);