Implement a QR solver wrapper
This commit is contained in:
parent
bb5d739e5d
commit
bb47b07422
10 changed files with 90 additions and 6 deletions
34
test/unit/functions/qr.cpp
Normal file
34
test/unit/functions/qr.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include <rotgen/rotgen.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,O::value>
|
||||
a { { 2.3, -1, 0.1}
|
||||
, {-1.6, 2.6, -1}
|
||||
, { 0.3, -1, 2}
|
||||
};
|
||||
|
||||
rotgen::matrix<T,rotgen::Dynamic,1,O::value> b(3,1);
|
||||
b(0) = b(2) = 1; b(1) = 0;
|
||||
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> 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";
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue