rotgen/test/unit/functions/qr.cpp
Joel Falcou c400650f1a Implements rotgen::quaternion
Closes #19

Co-authored-by: Jules Pénuchot <jules@penuchot.com>
2025-11-09 19:07:20 +01:00

36 lines
1.3 KiB
C++

//==================================================================================================
/*
ROTGEN - Runtime Overlay for Eigen
Copyright : CODE RECKONS
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#include <rotgen/rotgen.hpp>
#include "unit/tests.hpp"
TTS_CASE_TPL("System solver using QR",
rotgen::tests::types)<typename T, typename O>(
tts::type<tts::types<T, O>>)
{
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic> a{{2.3, -1, 0.1},
{-1.6, 2.6, -1},
{0.3, -1, 2}};
rotgen::matrix<T, rotgen::Dynamic, 1> b(3, 1);
b(0) = b(2) = 1;
b(1) = 0;
rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic> r(3, 1), error;
auto x = rotgen::extract(r, 0, 0, 3, 1);
rotgen::solver::qr(x, a, b);
error = a * r - b;
auto eps = std::numeric_limits<T>::epsilon();
TTS_LESS(rotgen::maxCoeff(rotgen::abs(error)) / eps, 5) << "Result:\n"
<< r << "\n"
<< "Residuals:\n"
<< error << "\n";
};