//================================================================================================== /* ROTGEN - Runtime Overlay for Eigen Copyright : CODE RECKONS SPDX-License-Identifier: BSL-1.0 */ //================================================================================================== #include #include "unit/common/references.hpp" #include "unit/tests.hpp" TTS_CASE_TPL("Test dynamic matrix inverse", rotgen::tests::types) (tts::type>) { using mat_t = rotgen::matrix; auto eps = std::numeric_limits::epsilon(); for (int n = 2; n < 15; n *= 1.5) { auto input = 10 * rotgen::setRandom(n, n); auto inv = rotgen::inverse(input); auto rec = input * inv; auto id = rotgen::setIdentity(rotgen::rows(rec), rotgen::cols(rec)); auto error = rec - id; TTS_LESS_EQUAL(rotgen::maxCoeff(rotgen::abs(error)) / eps, 256.) << "Result:\n" << rec << "\n" << "Residuals:\n" << error << "\n"; } }; template void check_static_inverse() { using mat_t = rotgen::matrix; auto eps = std::numeric_limits::epsilon(); auto input = rotgen::setRandom(); auto inv = rotgen::inverse(input); auto rec = input * inv; auto id = rotgen::setIdentity(rotgen::rows(rec), rotgen::cols(rec)); auto error = rec - id; TTS_LESS_EQUAL(rotgen::maxCoeff(rotgen::abs(error)) / eps, 256.) << "Result:\n" << rec << "\n" << "Residuals:\n" << error << "\n"; } TTS_CASE_TPL("Test static matrix inverse", rotgen::tests::types) (tts::type>) { check_static_inverse(); check_static_inverse(); check_static_inverse(); check_static_inverse(); check_static_inverse(); check_static_inverse(); };