Skip to content

Commit

Permalink
Tests: add lindex_to_pos_arr
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJoube committed Jun 2, 2024
1 parent 5b66db8 commit 2a8e5aa
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,40 @@ std::array<std::size_t, 4> lindex_to_pos_arr( std::size_t const d1
return p;
}

std::array<std::size_t, 4> std_res_to_pos4D ( int* res
, int* begin
, std::size_t const d1
, std::size_t const d2
, std::size_t const d3
)
std::array<std::size_t, 2> lindex_to_pos_arr( std::size_t const d1
, int const lindex
)
{
auto dist = static_cast<std::size_t>(std::distance(begin, res));
int remains = lindex;
std::array<std::size_t, 2> p;
std::fill(p.begin(), p.end(), 0);
p[0] = remains / d1;
remains -= p[0] * d1;
p[1] = remains;
return p;
}

std::array<std::size_t, 4> std_res_to_pos ( int* res
, int* begin
, std::size_t const d1
, std::size_t const d2
, std::size_t const d3
)
{
std::size_t dist = static_cast<std::size_t>(std::distance(begin, res));
return lindex_to_pos_arr(d1, d2, d3, dist);
}

std::array<std::size_t, 2> std_res_to_pos ( int* res
, int* begin
, std::size_t const d1
)
{
std::size_t dist = static_cast<std::size_t>(std::distance(begin, res));
return lindex_to_pos_arr(d1, dist);
}



template<typename T, typename S>
void fill_data(T* data, S shp, bool fill)
Expand Down

0 comments on commit 2a8e5aa

Please sign in to comment.