Skip to content

Commit

Permalink
replace detail::disjoint_subset with set_difference
Browse files Browse the repository at this point in the history
Change-Id: I0580efc61146d808ccf94edb283d95398a17a624
  • Loading branch information
oliverlee committed Sep 29, 2024
1 parent 4975653 commit 0d87890
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 109 deletions.
1 change: 0 additions & 1 deletion rigid_geometric_algebra/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ cc_library(
"detail/derive_subtraction.hpp",
"detail/derive_vector_space_operations.hpp",
"detail/derive_zero_constant_overload.hpp",
"detail/disjoint_subset.hpp",
"detail/even.hpp",
"detail/has_type.hpp",
"detail/has_value.hpp",
Expand Down
31 changes: 19 additions & 12 deletions rigid_geometric_algebra/blade_complement_type.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#pragma once

#include "rigid_geometric_algebra/algebra_dimension.hpp"
#include "rigid_geometric_algebra/algebra_type.hpp"
#include "rigid_geometric_algebra/blade_type_from.hpp"
#include "rigid_geometric_algebra/detail/disjoint_subset.hpp"
#include "rigid_geometric_algebra/canonical_type.hpp"
#include "rigid_geometric_algebra/is_blade.hpp"

#include <algorithm>
#include <array>
#include <cstddef>
#include <ranges>
#include <type_traits>
#include <utility>

namespace rigid_geometric_algebra {
namespace detail {
Expand All @@ -15,18 +19,21 @@ template <bool, class>
struct blade_complement_type_
{};

template <
template <class, std::size_t...> class blade_,
class A,
std::size_t... Is>
struct blade_complement_type_<true, blade_<A, Is...>>
template <class B>
struct blade_complement_type_<true, B>
{
static constexpr auto complement_dimensions =
[]<std::size_t... Js>(std::index_sequence<Js...>) {
return detail::disjoint_subset(Is..., Js...);
}(std::make_index_sequence<algebra_dimension_v<A>>{});
using A = algebra_type_t<B>;

using type = blade_type_from_dimensions_t<A, complement_dimensions>;
using type = blade_type_from_dimensions_t<A, [] {
auto missing = std::array<std::size_t, algebra_dimension_v<A> - B::grade>{};

std::ranges::set_difference(
std::views::iota(0UZ, algebra_dimension_v<A>),
canonical_type_t<B>::dimensions,
missing.begin());

return missing;
}()>;
};

} // namespace detail
Expand Down
57 changes: 0 additions & 57 deletions rigid_geometric_algebra/detail/disjoint_subset.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions test/blade_type_from_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ auto main() -> int
same<G2::blade<>, blade_type_from_dimensions_t<G2, {}>>() and
same<G2::blade<0>, blade_type_from_dimensions_t<G2, {0}>>() and
same<G2::blade<1, 2>, blade_type_from_dimensions_t<G2, {1, 2}>>() and
same<G2::blade<2, 1, 0>, blade_type_from_dimensions_t<G2, {2, 1, 0}>>()
);
same<G2::blade<2, 1, 0>,
blade_type_from_dimensions_t<G2, {2, 1, 0}>>());
};
}
10 changes: 0 additions & 10 deletions test/detail/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ cc_test(
],
)

cc_test(
name = "disjoint_subset_test",
size = "small",
srcs = ["disjoint_subset_test.cpp"],
deps = [
"//rigid_geometric_algebra",
"@skytest",
],
)

cc_test(
name = "has_type_test",
size = "small",
Expand Down
27 changes: 0 additions & 27 deletions test/detail/disjoint_subset_test.cpp

This file was deleted.

0 comments on commit 0d87890

Please sign in to comment.