//================================================================================================== /* ROTGEN - Runtime Overlay for Eigen Copyright : CODE RECKONS SPDX-License-Identifier: BSL-1.0 */ //================================================================================================== #include #include "unit/tests.hpp" bool categorize_as_scalar(double) { return true; } bool categorize_as_scalar(rotgen::ref>) { return false; } TTS_CASE("Matrix product of 1xN by Nx1 yields a scalar-convertible object") { rotgen::matrix a = {1, 2}; rotgen::matrix 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) (tts::type>) { rotgen::matrix a = {1, 2}; rotgen::matrix b = {10, 20}; rotgen::matrix big(10, 10); auto bk = extract<1, 1>(big, 2, 2); bk = a * b; TTS_EQUAL(big(2, 2), 50); rotgen::map> big_map(big.data(), 1, 1); big_map = a * b; TTS_EQUAL(big(0, 0), 50); };