Fix a lot of ref issues reagrding extarction, rvalueness and proper use of temporary memory.
This commit is contained in:
parent
d5c41bf43e
commit
379d77ebef
50 changed files with 2945 additions and 1397 deletions
|
|
@ -5,9 +5,10 @@
|
|||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
#include "unit/tests.hpp"
|
||||
|
||||
template<typename EigenType, typename F>
|
||||
void for_each_element(EigenType const& m, F&& f)
|
||||
{
|
||||
|
|
@ -137,68 +138,81 @@ void test_dynamic_block_extraction(
|
|||
auto blocks = std::make_tuple(
|
||||
// --- CONST TESTS
|
||||
std::make_tuple(c_block_main, matrix_construct.i0, matrix_construct.j0,
|
||||
matrix_construct.ni, matrix_construct.nj),
|
||||
matrix_construct.ni, matrix_construct.nj, rotgen::Dynamic,
|
||||
rotgen::Dynamic),
|
||||
std::make_tuple(c_block_top_left_corner, 0, 0, matrix_construct.ni,
|
||||
matrix_construct.nj),
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_top_right_corner, 0,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj),
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_bottom_left_corner,
|
||||
matrix.rows() - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
matrix_construct.nj),
|
||||
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,
|
||||
matrix_construct.nj),
|
||||
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, matrix.cols(),
|
||||
rotgen::Dynamic, MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(c_block_middle_rows, matrix_construct.i0, 0,
|
||||
matrix_construct.ni, matrix.cols()),
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(c_block_bottom_rows, matrix.rows() - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, matrix.cols()),
|
||||
|
||||
std::make_tuple(c_block_left_cols, 0, 0, matrix.rows(),
|
||||
matrix_construct.nj),
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(c_block_left_cols, 0, 0, matrix.rows(), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic),
|
||||
std::make_tuple(c_block_middle_cols, 0, matrix_construct.j0, matrix.rows(),
|
||||
matrix_construct.nj),
|
||||
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),
|
||||
matrix.rows(), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic),
|
||||
|
||||
// --- REGULAR TESTS
|
||||
std::make_tuple(block_main, matrix_construct.i0, matrix_construct.j0,
|
||||
matrix_construct.ni, matrix_construct.nj),
|
||||
matrix_construct.ni, matrix_construct.nj, rotgen::Dynamic,
|
||||
rotgen::Dynamic),
|
||||
std::make_tuple(block_top_left_corner, 0, 0, matrix_construct.ni,
|
||||
matrix_construct.nj),
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(block_top_right_corner, 0,
|
||||
matrix.cols() - matrix_construct.nj, matrix_construct.ni,
|
||||
matrix_construct.nj),
|
||||
matrix_construct.nj, rotgen::Dynamic, rotgen::Dynamic),
|
||||
std::make_tuple(block_bottom_left_corner,
|
||||
matrix.rows() - matrix_construct.ni, 0, matrix_construct.ni,
|
||||
matrix_construct.nj),
|
||||
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,
|
||||
matrix_construct.nj),
|
||||
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, matrix.cols(),
|
||||
rotgen::Dynamic, MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(block_middle_rows, matrix_construct.i0, 0,
|
||||
matrix_construct.ni, matrix.cols()),
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(block_bottom_rows, matrix.rows() - matrix_construct.ni, 0,
|
||||
matrix_construct.ni, matrix.cols()),
|
||||
|
||||
std::make_tuple(block_left_cols, 0, 0, matrix.rows(), matrix_construct.nj),
|
||||
matrix_construct.ni, matrix.cols(), rotgen::Dynamic,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
std::make_tuple(block_left_cols, 0, 0, matrix.rows(), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic),
|
||||
std::make_tuple(block_middle_cols, 0, matrix_construct.j0, matrix.rows(),
|
||||
matrix_construct.nj),
|
||||
matrix_construct.nj, MatrixType::RowsAtCompileTime,
|
||||
rotgen::Dynamic),
|
||||
std::make_tuple(block_right_cols, 0, matrix.cols() - matrix_construct.nj,
|
||||
matrix.rows(), matrix_construct.nj));
|
||||
matrix.rows(), matrix_construct.nj,
|
||||
MatrixType::RowsAtCompileTime, rotgen::Dynamic));
|
||||
|
||||
std::apply(
|
||||
[&](auto&&... block_entries) {
|
||||
(([&] {
|
||||
auto&& [block, i_offset, j_offset, ni, nj] = block_entries;
|
||||
auto&& [block, i_offset, j_offset, ni, nj, rows_ct, cols_ct] =
|
||||
block_entries;
|
||||
using block_t = std::remove_reference_t<decltype(block)>;
|
||||
|
||||
TTS_EQUAL(block_t::RowsAtCompileTime, rotgen::Dynamic);
|
||||
TTS_EQUAL(block_t::ColsAtCompileTime, rotgen::Dynamic);
|
||||
TTS_EQUAL(block_t::RowsAtCompileTime, rows_ct);
|
||||
TTS_EQUAL(block_t::ColsAtCompileTime, cols_ct);
|
||||
TTS_EQUAL(block_t::storage_order, MatrixType::storage_order);
|
||||
|
||||
validate_block_behavior(matrix, block, i_offset, j_offset, ni, nj);
|
||||
|
|
@ -346,7 +360,7 @@ TTS_CASE_TPL(
|
|||
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, 1>;
|
||||
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, rotgen::RowMajor>;
|
||||
|
||||
std::vector<rotgen::tests::matrix_block_test_case<mat_t>> cases = {
|
||||
{{6, 11, [](rotgen::Index i, rotgen::Index j) { return T(i * 10 + j); }},
|
||||
|
|
@ -381,7 +395,7 @@ 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>>)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, 4, 5, O::value, 0>;
|
||||
using mat_t = rotgen::matrix<T, 4, 5, rotgen::ColMajor>;
|
||||
|
||||
std::vector<rotgen::tests::matrix_block_test_case<mat_t>> cases = {
|
||||
{{4, 5, [](auto i, auto j) { return T(2 * i + j * j * j - 42); }},
|
||||
|
|
@ -447,7 +461,7 @@ TTS_CASE_TPL("Check vector-only extractions",
|
|||
|
||||
if constexpr (O::value == rotgen::RowMajor)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, 1, rotgen::Dynamic, O::value>;
|
||||
using mat_t = rotgen::matrix<T, 1, rotgen::Dynamic>;
|
||||
mat_t m(1, 11);
|
||||
|
||||
for (rotgen::Index i = 0; i < 11; ++i) m(i) = 1 + i;
|
||||
|
|
@ -473,7 +487,7 @@ TTS_CASE_TPL("Check vector-only extractions",
|
|||
}
|
||||
else
|
||||
{
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, 1, O::value>;
|
||||
using mat_t = rotgen::matrix<T, rotgen::Dynamic, 1>;
|
||||
mat_t m(11, 1);
|
||||
|
||||
for (rotgen::Index i = 0; i < 11; ++i) m(i) = 1 + i;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue