Resolve "[API-#2] Pseudo-privatization of rotgen entity member functions"
Closes #18 Co-authored-by: Jules Pénuchot <jules@penuchot.com> See merge request oss/rotgen!50
This commit is contained in:
parent
6489697c05
commit
e151e136d6
52 changed files with 2212 additions and 1556 deletions
|
|
@ -13,15 +13,15 @@
|
|||
template<typename EigenType, typename F>
|
||||
void for_each_element(EigenType const& m, F&& f)
|
||||
{
|
||||
for (rotgen::Index i = 0; i < m.rows(); ++i)
|
||||
for (rotgen::Index j = 0; j < m.cols(); ++j) f(i, j, m(i, j));
|
||||
for (rotgen::Index i = 0; i < rows(m); ++i)
|
||||
for (rotgen::Index j = 0; j < cols(m); ++j) f(i, j, m(i, j));
|
||||
}
|
||||
|
||||
template<typename EigenType, typename F>
|
||||
void for_each_element(EigenType& m, F&& f)
|
||||
{
|
||||
for (rotgen::Index i = 0; i < m.rows(); ++i)
|
||||
for (rotgen::Index j = 0; j < m.cols(); ++j) f(i, j, m(i, j));
|
||||
for (rotgen::Index i = 0; i < rows(m); ++i)
|
||||
for (rotgen::Index j = 0; j < cols(m); ++j) f(i, j, m(i, j));
|
||||
}
|
||||
|
||||
template<typename MatrixType, typename T>
|
||||
|
|
@ -53,8 +53,8 @@ void validate_block_behavior(MatrixType& matrix,
|
|||
rotgen::Index block_n)
|
||||
{
|
||||
using T = typename MatrixType::value_type;
|
||||
TTS_EQUAL(block.rows(), block_m);
|
||||
TTS_EQUAL(block.cols(), block_n);
|
||||
TTS_EQUAL(rows(block), block_m);
|
||||
TTS_EQUAL(cols(block), block_n);
|
||||
TTS_EQUAL(block.size(), block_m * block_n);
|
||||
|
||||
// test block values
|
||||
|
|
@ -144,31 +144,31 @@ void test_dynamic_block_extraction(
|
|||
std::make_tuple(c_block_top_left_corner, 0, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_top_right_corner, 0,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_bottom_left_corner,
|
||||
matrix.rows() - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_bottom_right_corner,
|
||||
matrix.rows() - matrix_construct.ni,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
|
||||
std::make_tuple(c_block_top_rows, 0, 0, matrix_construct.ni, matrix.cols(),
|
||||
std::make_tuple(c_block_top_rows, 0, 0, matrix_construct.ni, cols(matrix),
|
||||
rotgen::Dynamic, MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(c_block_middle_rows, matrix_construct.i0, 0,
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
matrix_construct.ni, cols(matrix), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(c_block_bottom_rows, matrix.rows() - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
std::make_tuple(c_block_bottom_rows, rows(matrix) - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, cols(matrix), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(c_block_left_cols, 0, 0, matrix.rows(), matrix_construct.nj,
|
||||
std::make_tuple(c_block_left_cols, 0, 0, rows(matrix), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_middle_cols, 0, matrix_construct.j0, matrix.rows(),
|
||||
std::make_tuple(c_block_middle_cols, 0, matrix_construct.j0, rows(matrix),
|
||||
matrix_construct.nj, MatrixType::RowsAtCompileTime,
|
||||
rotgen::Dynamic),
|
||||
std::make_tuple(c_block_right_cols, 0, matrix.cols() - matrix_construct.nj,
|
||||
matrix.rows(), matrix_construct.nj,
|
||||
std::make_tuple(c_block_right_cols, 0, cols(matrix) - matrix_construct.nj,
|
||||
rows(matrix), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic),
|
||||
|
||||
// --- REGULAR TESTS
|
||||
|
|
@ -178,31 +178,31 @@ void test_dynamic_block_extraction(
|
|||
std::make_tuple(block_top_left_corner, 0, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(block_top_right_corner, 0,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(block_bottom_left_corner,
|
||||
matrix.rows() - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(block_bottom_right_corner,
|
||||
matrix.rows() - matrix_construct.ni,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
|
||||
std::make_tuple(block_top_rows, 0, 0, matrix_construct.ni, matrix.cols(),
|
||||
std::make_tuple(block_top_rows, 0, 0, matrix_construct.ni, cols(matrix),
|
||||
rotgen::Dynamic, MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(block_middle_rows, matrix_construct.i0, 0,
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
matrix_construct.ni, cols(matrix), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(block_bottom_rows, matrix.rows() - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
std::make_tuple(block_bottom_rows, rows(matrix) - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, cols(matrix), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(block_left_cols, 0, 0, matrix.rows(), matrix_construct.nj,
|
||||
std::make_tuple(block_left_cols, 0, 0, rows(matrix), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic),
|
||||
std::make_tuple(block_middle_cols, 0, matrix_construct.j0, matrix.rows(),
|
||||
std::make_tuple(block_middle_cols, 0, matrix_construct.j0, rows(matrix),
|
||||
matrix_construct.nj, MatrixType::RowsAtCompileTime,
|
||||
rotgen::Dynamic),
|
||||
std::make_tuple(block_right_cols, 0, matrix.cols() - matrix_construct.nj,
|
||||
matrix.rows(), matrix_construct.nj,
|
||||
std::make_tuple(block_right_cols, 0, cols(matrix) - matrix_construct.nj,
|
||||
rows(matrix), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic));
|
||||
|
||||
std::apply(
|
||||
|
|
@ -276,68 +276,68 @@ void test_static_block_extraction(
|
|||
std::make_tuple(c_block_top_left_corner, 0, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
std::make_tuple(c_block_top_right_corner, 0,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
std::make_tuple(c_block_bottom_left_corner,
|
||||
matrix.rows() - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
std::make_tuple(c_block_bottom_right_corner,
|
||||
matrix.rows() - matrix_construct.ni,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
|
||||
std::make_tuple(c_block_top_rows, 0, 0, matrix_construct.ni, matrix.cols(),
|
||||
std::make_tuple(c_block_top_rows, 0, 0, matrix_construct.ni, cols(matrix),
|
||||
int(NI), rotgen::Dynamic),
|
||||
std::make_tuple(c_block_middle_rows, i0, 0, matrix_construct.ni,
|
||||
matrix.cols(), int(NI), rotgen::Dynamic),
|
||||
std::make_tuple(c_block_bottom_rows, matrix.rows() - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, matrix.cols(), int(NI),
|
||||
cols(matrix), int(NI), rotgen::Dynamic),
|
||||
std::make_tuple(c_block_bottom_rows, rows(matrix) - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, cols(matrix), int(NI),
|
||||
rotgen::Dynamic),
|
||||
|
||||
std::make_tuple(c_block_left_cols, 0, 0, matrix.rows(), matrix_construct.nj,
|
||||
std::make_tuple(c_block_left_cols, 0, 0, rows(matrix), matrix_construct.nj,
|
||||
rotgen::Dynamic, int(NJ)),
|
||||
std::make_tuple(c_block_middle_cols, 0, j0, matrix.rows(),
|
||||
std::make_tuple(c_block_middle_cols, 0, j0, rows(matrix),
|
||||
matrix_construct.nj, rotgen::Dynamic, int(NJ)),
|
||||
std::make_tuple(c_block_right_cols, 0, matrix.cols() - matrix_construct.nj,
|
||||
matrix.rows(), matrix_construct.nj, rotgen::Dynamic,
|
||||
std::make_tuple(c_block_right_cols, 0, cols(matrix) - matrix_construct.nj,
|
||||
rows(matrix), matrix_construct.nj, rotgen::Dynamic,
|
||||
int(NJ)),
|
||||
|
||||
std::make_tuple(c_block_row, i0, 0, 1, matrix.cols(), 1, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_col, 0, j0, matrix.rows(), 1, rotgen::Dynamic, 1),
|
||||
std::make_tuple(c_block_row, i0, 0, 1, cols(matrix), 1, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_col, 0, j0, rows(matrix), 1, rotgen::Dynamic, 1),
|
||||
// -- Block to NON CONST
|
||||
std::make_tuple(block_main, i0, j0, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
std::make_tuple(block_top_left_corner, 0, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
std::make_tuple(block_top_right_corner, 0,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
std::make_tuple(block_bottom_left_corner,
|
||||
matrix.rows() - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
std::make_tuple(block_bottom_right_corner,
|
||||
matrix.rows() - matrix_construct.ni,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
rows(matrix) - matrix_construct.ni,
|
||||
cols(matrix) - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj, int(NI), int(NJ)),
|
||||
|
||||
std::make_tuple(block_top_rows, 0, 0, matrix_construct.ni, matrix.cols(),
|
||||
std::make_tuple(block_top_rows, 0, 0, matrix_construct.ni, cols(matrix),
|
||||
int(NI), rotgen::Dynamic),
|
||||
std::make_tuple(block_middle_rows, i0, 0, matrix_construct.ni,
|
||||
matrix.cols(), int(NI), rotgen::Dynamic),
|
||||
std::make_tuple(block_bottom_rows, matrix.rows() - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, matrix.cols(), int(NI),
|
||||
std::make_tuple(block_middle_rows, i0, 0, matrix_construct.ni, cols(matrix),
|
||||
int(NI), rotgen::Dynamic),
|
||||
std::make_tuple(block_bottom_rows, rows(matrix) - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, cols(matrix), int(NI),
|
||||
rotgen::Dynamic),
|
||||
|
||||
std::make_tuple(block_left_cols, 0, 0, matrix.rows(), matrix_construct.nj,
|
||||
std::make_tuple(block_left_cols, 0, 0, rows(matrix), matrix_construct.nj,
|
||||
rotgen::Dynamic, int(NJ)),
|
||||
std::make_tuple(block_middle_cols, 0, j0, matrix.rows(),
|
||||
matrix_construct.nj, rotgen::Dynamic, int(NJ)),
|
||||
std::make_tuple(block_right_cols, 0, matrix.cols() - matrix_construct.nj,
|
||||
matrix.rows(), matrix_construct.nj, rotgen::Dynamic,
|
||||
std::make_tuple(block_middle_cols, 0, j0, rows(matrix), matrix_construct.nj,
|
||||
rotgen::Dynamic, int(NJ)),
|
||||
std::make_tuple(block_right_cols, 0, cols(matrix) - matrix_construct.nj,
|
||||
rows(matrix), matrix_construct.nj, rotgen::Dynamic,
|
||||
int(NJ)),
|
||||
|
||||
std::make_tuple(block_row, i0, 0, 1, matrix.cols(), 1, rotgen::Dynamic),
|
||||
std::make_tuple(block_col, 0, j0, matrix.rows(), 1, rotgen::Dynamic, 1));
|
||||
std::make_tuple(block_row, i0, 0, 1, cols(matrix), 1, rotgen::Dynamic),
|
||||
std::make_tuple(block_col, 0, j0, rows(matrix), 1, rotgen::Dynamic, 1));
|
||||
|
||||
std::apply(
|
||||
[&](auto&&... block_entries) {
|
||||
|
|
@ -358,7 +358,9 @@ void test_static_block_extraction(
|
|||
|
||||
TTS_CASE_TPL(
|
||||
"Check all dynamic block extractions on a dynamic row-major matrix",
|
||||
rotgen::tests::types)<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t =
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, rotgen::RowMajor>;
|
||||
|
|
@ -394,7 +396,9 @@ TTS_CASE_TPL(
|
|||
|
||||
TTS_CASE_TPL(
|
||||
"Check all dynamic block extractions on a static column-major matrix",
|
||||
rotgen::tests::types)<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, 4, 5, rotgen::ColMajor>;
|
||||
|
||||
|
|
@ -417,9 +421,9 @@ TTS_CASE_TPL(
|
|||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check all static block extractions",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Check all static block extractions", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>;
|
||||
|
||||
|
|
@ -446,9 +450,9 @@ TTS_CASE_TPL("Check all static block extractions",
|
|||
0});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check vector-only extractions",
|
||||
rotgen::tests::types)<typename T, typename O>(
|
||||
tts::type<tts::types<T, O>>)
|
||||
TTS_CASE_TPL("Check vector-only extractions", rotgen::tests::types)
|
||||
|
||||
<typename T, typename O>(tts::type<tts::types<T, O>>)
|
||||
{
|
||||
auto run_case = [](auto&& matrix, auto&& block, int i_offset, int j_offset,
|
||||
int ni, int nj, auto const& rows_ct, auto const& cols_ct) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue