philsupertramp/game-math
Loading...
Searching...
No Matches
numerics/lin_alg/TestQR.cpp

This is an example on how to use the qr decomposition.

#include "../../Test.h"
class QRTestCase : public Test
{
bool TestQR() {
Matrix<double> A = { { 2, 2, 8 }, { 5, 6, 6 }, { 4, 4, 8 } };
//
// R *= -1.0;
// Q *= -1.0;
auto result = qr(A);
AssertEqual(A, result.first * result.second);
A = { { 2, 3 }, { 3, 2 } };
result = qr(A);
AssertEqual(A, result.first * result.second);
return true;
}
public:
void run() override { TestQR(); }
};
int main() {
QRTestCase().run();
return 0;
}
Definition: Matrix.h:42
std::pair< Matrix< double >, Matrix< double > > qr(const Matrix< double > &A)
Definition: qr.h:12