//================================================================================================== /* ROTGEN - Runtime Overlay for Eigen Copyright : CODE RECKONS SPDX-License-Identifier: BSL-1.0 */ //================================================================================================== #include "unit/tests.hpp" #include TTS_CASE_TPL("map constructor from pointer and single static size", rotgen::tests::types)( tts::type>) { T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; rotgen::map> row_map(data); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(row_map(i), data[i]); rotgen::map const> const_row_map( data); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(const_row_map(i), data[i]); rotgen::map> col_map(data); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(col_map(i), data[i]); rotgen::map const> const_col_map( data); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(const_col_map(i), data[i]); }; TTS_CASE_TPL("map constructor from pointer and static size", rotgen::tests::types)( tts::type>) { using base = rotgen::matrix; T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; rotgen::map dyn_map(data); for (rotgen::Index i = 0; i < 4; i++) { for (rotgen::Index j = 0; j < 3; j++) { if constexpr (O::value) TTS_EQUAL(dyn_map(i, j), data[j + 3 * i]); else TTS_EQUAL(dyn_map(i, j), data[i + 4 * j]); } } }; TTS_CASE_TPL("map constructor from pointer and single dynamic size", rotgen::tests::types)( tts::type>) { T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; rotgen::map> row_map( data, 12); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(row_map(i), data[i]); rotgen::map const> const_row_map(data, 12); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(const_row_map(i), data[i]); rotgen::map> col_map( data, 12); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(col_map(i), data[i]); rotgen::map const> const_col_map(data, 12); for (rotgen::Index i = 0; i < 12; i++) TTS_EQUAL(const_col_map(i), data[i]); }; TTS_CASE_TPL("map constructor from pointer and dynamic size", rotgen::tests::types)( tts::type>) { using base = rotgen::matrix; T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; rotgen::map dyn_map(data, 4, 3); for (rotgen::Index i = 0; i < 4; i++) { for (rotgen::Index j = 0; j < 3; j++) { if constexpr (O::value) TTS_EQUAL(dyn_map(i, j), data[j + 3 * i]); else TTS_EQUAL(dyn_map(i, j), data[i + 4 * j]); } } };