Skip to content

Commit

Permalink
Rename is_inside to contains
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Jan 16, 2025
1 parent 66485d5 commit f297957
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions include/ddc/chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
SupportType::rank() == (0 + ... + DElems::size()),
"Invalid number of dimensions");
static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
assert(this->m_domain.is_inside(delems...));
assert(this->m_domain.contains(delems...));
return DDC_MDSPAN_ACCESS_OP(
this->m_allocation_mdspan,
detail::array(this->m_domain.distance_from_front(delems...)));
Expand All @@ -466,7 +466,7 @@ class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
SupportType::rank() == (0 + ... + DElems::size()),
"Invalid number of dimensions");
static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
assert(this->m_domain.is_inside(delems...));
assert(this->m_domain.contains(delems...));
return DDC_MDSPAN_ACCESS_OP(
this->m_allocation_mdspan,
detail::array(this->m_domain.distance_from_front(delems...)));
Expand Down
2 changes: 1 addition & 1 deletion include/ddc/chunk_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class ChunkSpan : public ChunkCommon<ElementType, SupportType, LayoutStridedPoli
SupportType::rank() == (0 + ... + DElems::size()),
"Invalid number of dimensions");
static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
assert(this->m_domain.is_inside(delems...));
assert(this->m_domain.contains(delems...));
return DDC_MDSPAN_ACCESS_OP(
this->m_allocation_mdspan,
detail::array(this->m_domain.distance_from_front(delems...)));
Expand Down
6 changes: 3 additions & 3 deletions include/ddc/discrete_domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class DiscreteDomain
}

template <class... DElems>
bool is_inside(DElems const&... delems) const noexcept
bool contains(DElems const&... delems) const noexcept
{
static_assert(
sizeof...(DDims) == (0 + ... + DElems::size()),
Expand Down Expand Up @@ -400,12 +400,12 @@ class DiscreteDomain<>
return *this;
}

static bool is_inside() noexcept
static bool contains() noexcept
{
return true;
}

static bool is_inside(DiscreteElement<>) noexcept
static bool contains(DiscreteElement<>) noexcept
{
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions include/ddc/storage_discrete_domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class StorageDiscreteDomain
// }

template <class... DElems>
KOKKOS_FUNCTION bool is_inside(DElems const&... delems) const noexcept
KOKKOS_FUNCTION bool contains(DElems const&... delems) const noexcept
{
static_assert(
sizeof...(DDims) == (0 + ... + DElems::size()),
Expand All @@ -296,7 +296,7 @@ class StorageDiscreteDomain
sizeof...(DDims) == (0 + ... + DElems::size()),
"Invalid number of dimensions");
static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
assert(is_inside(delems...));
assert(contains(delems...));
return DiscreteVector<DDims...>(
(detail::lower_bound(
get<DDims>(m_views).data(),
Expand Down Expand Up @@ -502,12 +502,12 @@ class StorageDiscreteDomain
// return *this;
// }

// static bool is_inside() noexcept
// static bool contains() noexcept
// {
// return true;
// }

// static bool is_inside(DiscreteElement<>) noexcept
// static bool contains(DiscreteElement<>) noexcept
// {
// return true;
// }
Expand Down
8 changes: 4 additions & 4 deletions include/ddc/strided_discrete_domain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class StridedDiscreteDomain
// }

template <class... DElems>
KOKKOS_FUNCTION bool is_inside(DElems const&... delems) const noexcept
KOKKOS_FUNCTION bool contains(DElems const&... delems) const noexcept
{
static_assert(
sizeof...(DDims) == (0 + ... + DElems::size()),
Expand Down Expand Up @@ -251,7 +251,7 @@ class StridedDiscreteDomain
sizeof...(DDims) == (0 + ... + DElems::size()),
"Invalid number of dimensions");
static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
assert(is_inside(delems...));
assert(contains(delems...));
return DiscreteVector<DDims...>(
((DiscreteElement<DDims>(take<DDims>(delems...))
- DiscreteElement<DDims>(m_element_begin))
Expand Down Expand Up @@ -455,12 +455,12 @@ class StridedDiscreteDomain<>
return *this;
}

static bool is_inside() noexcept
static bool contains() noexcept
{
return true;
}

static bool is_inside(DiscreteElement<>) noexcept
static bool contains(DiscreteElement<>) noexcept
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/discrete_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ TEST(DiscreteDomainTest, Remove)
TEST(DiscreteDomainTest, IsInside)
{
DDomXY const dom_x_y(lbound_x_y, nelems_x_y);
EXPECT_TRUE(dom_x_y.is_inside(lbound_x_y));
EXPECT_FALSE(dom_x_y.is_inside(lbound_x_y + nelems_x_y));
EXPECT_TRUE(dom_x_y.contains(lbound_x_y));
EXPECT_FALSE(dom_x_y.contains(lbound_x_y + nelems_x_y));
}

TEST(DiscreteDomainTest, DistanceFromFront)
Expand Down
2 changes: 1 addition & 1 deletion tests/storage_discrete_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ TEST(StorageDiscreteDomainTest, Constructor)
EXPECT_EQ(dom_xy.distance_from_front(lbound_x + 2, lbound_y + 0), DVectXY(1, 0));
EXPECT_EQ(dom_xy.distance_from_front(lbound_x + 2, lbound_y + 2), DVectXY(1, 1));
EXPECT_EQ(dom_xy.distance_from_front(lbound_x + 2, lbound_y + 5), DVectXY(1, 2));
EXPECT_FALSE(dom_xy.is_inside(lbound_x + 1, lbound_y + 0));
EXPECT_FALSE(dom_xy.contains(lbound_x + 1, lbound_y + 0));
}
4 changes: 2 additions & 2 deletions tests/strided_discrete_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ TEST(StridedDiscreteDomainTest, Remove)
TEST(StridedDiscreteDomainTest, IsInside)
{
DDomXY const dom_x_y(lbound_x_y, nelems_x_y, strides_x_y);
EXPECT_TRUE(dom_x_y.is_inside(lbound_x_y));
EXPECT_FALSE(dom_x_y.is_inside(lbound_x_y + DVectXY(1, 1)));
EXPECT_TRUE(dom_x_y.contains(lbound_x_y));
EXPECT_FALSE(dom_x_y.contains(lbound_x_y + DVectXY(1, 1)));
}

TEST(StridedDiscreteDomainTest, DistanceFromFront)
Expand Down

0 comments on commit f297957

Please sign in to comment.