Fix a lot of ref issues reagrding extarction, rvalueness and proper use of temporary memory.

This commit is contained in:
Joel Falcou 2025-10-28 20:12:33 +01:00
parent d5c41bf43e
commit 379d77ebef
50 changed files with 2945 additions and 1397 deletions

View file

@ -5,12 +5,13 @@
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#include "unit/tests.hpp"
#include <rotgen/rotgen.hpp>
TTS_CASE_TPL("Chains of extraction",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
#include "unit/tests.hpp"
TTS_CASE_TPL("Chains of extraction", rotgen::tests::types)
<typename T, typename O>(tts::type<tts::types<T, O>>)
{
constexpr int N = 8;
auto a = rotgen::matrix<T, N, N, O::value>::Random();
@ -44,6 +45,9 @@ TTS_CASE_TPL("Chains of extraction",
setConstant(bbbb, 0.125);
TTS_EQUAL(a(3, 3), 0.125);
bool verbose = ::tts::arguments()[{"--verbose"}];
if (verbose) std::cout << a << "\n\n";
};
auto ref_extract(rotgen::ref<rotgen::matrix<float>> m)
@ -66,9 +70,10 @@ TTS_CASE("Extraction of ref/ref const")
for (rotgen::Index r = 0; r < 3; r++)
for (rotgen::Index c = 0; c < 4; c++) TTS_EQUAL(m(r, c), 1.f);
auto sliced = ref_cextract(m);
rotgen::extract(m, 3, 4, 4, 3) =
rotgen::setConstant<rotgen::matrix<float, 4, 3>>(5);
auto sliced = ref_cextract(m);
for (rotgen::Index r = 0; r < 4; r++)
for (rotgen::Index c = 0; c < 3; c++) TTS_EQUAL(sliced(r, c), 5.f);
};