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

Commits on May 23, 2021

  1. Upgrade to VS 16.0 preview 4.

    pleroy committed May 23, 2021
    Copy the full SHA
    094e9ac View commit details
  2. Get the right coverage DLL.

    pleroy committed May 23, 2021
    Copy the full SHA
    4f497f1 View commit details
  3. Copy the full SHA
    49a6fbb View commit details

Commits on May 24, 2021

  1. Copy the full SHA
    971c152 View commit details
  2. Typo.

    pleroy committed May 24, 2021
    Copy the full SHA
    b28460e View commit details
  3. Merge pull request #2994 from pleroy/16.10Preview4

    Upgrade to VS 16.10.0 preview 4
    pleroy authored May 24, 2021
    Copy the full SHA
    8c32505 View commit details
3 changes: 2 additions & 1 deletion base/not_null_test.cpp
Original file line number Diff line number Diff line change
@@ -70,7 +70,8 @@ TEST_F(NotNullTest, Move) {
_MSC_FULL_VER == 192'528'611 || \
_MSC_FULL_VER == 192'628'806 || \
_MSC_FULL_VER == 192'729'111 || \
_MSC_FULL_VER == 192'829'333)
_MSC_FULL_VER == 192'829'333 || \
_MSC_FULL_VER == 192'930'036)
EXPECT_THAT(*(std::unique_ptr<int> const&)int_ptr1, Eq(3));
#endif
not_null<std::unique_ptr<int>> int_ptr2 = std::move(int_ptr1);
5 changes: 4 additions & 1 deletion coverage_analyser/coverage_analyser.csproj
Original file line number Diff line number Diff line change
@@ -34,10 +34,13 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.Coverage.Analysis, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=x86">
<Reference Condition="$(MSBuildVersion)!=16.10.0" Include="Microsoft.VisualStudio.Coverage.Analysis, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(VCTargetsPath)\..\..\..\..\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.Coverage.Analysis.dll</HintPath>
</Reference>
<Reference Condition="$(MSBuildVersion)==16.10.0" Include="Microsoft.VisualStudio.Coverage.Analysis.Net">
<HintPath>$(VCTargetsPath)\..\..\..\..\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Coverage.Analysis.Net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
2 changes: 1 addition & 1 deletion find_msbuild.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
param([switch]$strict = $false)

$version = "16.8.1"
$version = "16.10.0"
$preview = ""

if ($preview.length -gt 0) {
106 changes: 86 additions & 20 deletions numerics/double_precision_body.hpp
Original file line number Diff line number Diff line change
@@ -7,9 +7,14 @@
#include <cmath>
#include <cstring>
#include <string>
#include <type_traits>

#include "geometry/grassmann.hpp"
#include "geometry/point.hpp"
#include "geometry/r3_element.hpp"
#include "geometry/serialization.hpp"
#include "quantities/elementary_functions.hpp"
#include "quantities/quantities.hpp"
#include "quantities/si.hpp"

namespace principia {
@@ -18,33 +23,93 @@ namespace internal_double_precision {

using geometry::DoubleOrQuantityOrPointOrMultivectorSerializer;
using geometry::DoubleOrQuantityOrMultivectorSerializer;
using geometry::Multivector;
using geometry::Point;
using geometry::R3Element;
using quantities::Abs;
using quantities::FusedMultiplyAdd;
using quantities::is_quantity;
using quantities::Quantity;
using quantities::si::Radian;
namespace si = quantities::si;

// Assumes that |T| and |U| have a memory representation that is a sequence of
// |double|s, and returns the conjunction of componentwise
// |left[i]| >= |right[i]| or left[i] == 0.
// A helper to check that the preconditions of QuickTwoSum are met. Annoyingly
// complicated as it needs to peel off all of our abstractions until it reaches
// doubles.
template<typename T, typename U, typename = void>
struct ComponentwiseComparator;

template<typename T, typename U>
bool ComponentwiseGreaterThanOrEqualOrZero(T const& left, U const& right) {
static_assert(sizeof(left) == sizeof(right),
"Comparing types of different sizes");
static_assert(sizeof(left) % sizeof(double) == 0,
"Types are not sequences of doubles");
constexpr int size = sizeof(left) / sizeof(double);
std::array<double, size> left_doubles;
std::memcpy(left_doubles.data(), &left, sizeof(left));
std::array<double, size> right_doubles;
std::memcpy(right_doubles.data(), &right, sizeof(right));
bool result = true;
for (int i = 0; i < size; ++i) {
result &=
(Abs(left_doubles[i]) >= Abs(right_doubles[i]) || left_doubles[i] == 0);
struct ComponentwiseComparator<DoublePrecision<T>, DoublePrecision<U>> {
static bool GreaterThanOrEqualOrZero(DoublePrecision<T> const& left,
DoublePrecision<U> const& right) {
// This check is incomplete: it doesn't compare the errors component. To
// the best of my understanding this code is only used in tests.
return ComponentwiseComparator<T, U>::GreaterThanOrEqualOrZero(left.value,
right.value);
}
return result;
}
};

template<typename T, typename U>
struct ComponentwiseComparator<Point<T>, U> : base::not_constructible {
static bool GreaterThanOrEqualOrZero(Point<T> const& left,
U const& right) {
// We only care about the coordinates, the geometric structure is
// irrelevant.
return ComponentwiseComparator<T, U>::GreaterThanOrEqualOrZero(
left - Point<T>{}, right);
}
};

template<typename T, typename U>
struct ComponentwiseComparator<T, Point<U>> : base::not_constructible {
static bool GreaterThanOrEqualOrZero(T const& left,
Point<U> const& right) {
// We only care about the coordinates, the geometric structure is
// irrelevant.
return ComponentwiseComparator<T, U>::GreaterThanOrEqualOrZero(
left, right - Point<U>{});
}
};

template<typename T, typename TFrame, int trank,
typename U, typename UFrame, int urank>
struct ComponentwiseComparator<Multivector<T, TFrame, trank>,
Multivector<U, UFrame, urank>>
: base::not_constructible {
static bool GreaterThanOrEqualOrZero(
Multivector<T, TFrame, trank> const& left,
Multivector<U, UFrame, urank> const& right) {
// This doesn't handle trivectors.
return ComponentwiseComparator<R3Element<T>, R3Element<U>>::
GreaterThanOrEqualOrZero(left.coordinates(), right.coordinates());
}
};

template<typename T, typename U>
struct ComponentwiseComparator<R3Element<T>, R3Element<U>>
: base::not_constructible {
static bool GreaterThanOrEqualOrZero(R3Element<T> const& left,
R3Element<U> const& right) {
bool result = true;
for (int i = 0; i < 3; ++i) {
result &= ComponentwiseComparator<T, U>::GreaterThanOrEqualOrZero(
left[i], right[i]);
}
return result;
}
};

template<typename T, typename U>
struct ComponentwiseComparator<T, U,
std::enable_if_t<
std::conjunction_v<is_quantity<T>,
is_quantity<U>>>> {
static bool GreaterThanOrEqualOrZero(T const& left, U const& right) {
return Abs(left) >= Abs(right) || left == T{};
}
};


template<typename T>
constexpr DoublePrecision<T>::DoublePrecision(T const& value)
@@ -156,7 +221,8 @@ FORCE_INLINE(inline)
DoublePrecision<Sum<T, U>> QuickTwoSum(T const& a, U const& b) {
#if _DEBUG
using quantities::DebugString;
CHECK(ComponentwiseGreaterThanOrEqualOrZero(a, b))
using Comparator = ComponentwiseComparator<T, U>;
CHECK(Comparator::GreaterThanOrEqualOrZero(a, b))
<< "|" << DebugString(a) << "| < |" << DebugString(b) << "|";
#endif
// [HLB07].
7 changes: 0 additions & 7 deletions numerics/double_precision_test.cpp
Original file line number Diff line number Diff line change
@@ -41,13 +41,6 @@ using ::testing::Eq;
using ::testing::Ge;
using ::testing::Ne;

// Let's not try to compare those things.
template<typename T, typename U>
bool ComponentwiseGreaterThanOrEqualOrZero(DoublePrecision<T> const& left,
DoublePrecision<U> const& right) {
return true;
}

constexpr double ε = std::numeric_limits<double>::epsilon();
constexpr double ε² = ε * ε;
constexpr double ε³ = ε² * ε;
2 changes: 0 additions & 2 deletions numerics/unbounded_arrays_body.hpp
Original file line number Diff line number Diff line change
@@ -21,9 +21,7 @@ using quantities::Sqrt;
template<class T>
template<class U, class... Args>
inline void uninitialized_allocator<T>::construct(U* const p, Args&&... args) {
#if PRINCIPIA_COMPILER_CLANG
::new ((void*)p) U(std::forward<Args>(args)...); // NOLINT
#endif
}

template<typename Scalar>
4 changes: 3 additions & 1 deletion principia.props
Original file line number Diff line number Diff line change
@@ -123,7 +123,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link></Link>
<Link>
<AdditionalOptions>/ignore:4099</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<!--Release options.-->
<PropertyGroup Condition="$(PrincipiaOptimize)">