rotgen/test/integration/specifics.cpp
Joel Falcou 8e80d1d083 More specific fixes
See merge request oss/rotgen!47
2025-12-02 14:40:01 +01:00

50 lines
1.2 KiB
C++

//==================================================================================================
/*
ROTGEN - Runtime Overlay for Eigen
Copyright : CODE RECKONS
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#include <rotgen/rotgen.hpp>
#include "unit/tests.hpp"
bool categorize_as_scalar(double)
{
return true;
}
bool categorize_as_scalar(rotgen::ref<rotgen::matrix<double, 1, 1>>)
{
return false;
}
TTS_CASE("Matrix product of 1xN by Nx1 yields a scalar-convertible object")
{
rotgen::matrix<double, 1, 2> a = {1, 2};
rotgen::matrix<double, 2, 1> b = {10, 20};
double n = a * b;
TTS_EQUAL(n, 50);
TTS_EXPECT(categorize_as_scalar(a * b));
};
TTS_CASE_TPL("Static 1x1 matrix-like objects can be assigned as-if",
rotgen::tests::types)
<typename T, typename O>(tts::type<tts::types<T, O>>)
{
rotgen::matrix<T, 1, 2> a = {1, 2};
rotgen::matrix<T, 2, 1> b = {10, 20};
rotgen::matrix<T, -1, -1, O::value> big(10, 10);
auto bk = extract<1, 1>(big, 2, 2);
bk = a * b;
TTS_EQUAL(big(2, 2), 50);
rotgen::map<rotgen::matrix<T, 1, 1, O::value>> big_map(big.data(), 1, 1);
big_map = a * b;
TTS_EQUAL(big(0, 0), 50);
};