This is an example on how to use backwardSub.
#include "../../Test.h"
#include <vector>
class BackwardSubTestCase : public Test
{
bool TestBackwardSub() {
std::vector<double> LsgX = { 0.1246376811594203, 0.0652173913043478 };
for(size_t i = 0; i < 2; i++) { AssertEqual(x(i, 0), LsgX[i]); }
R = { { 4, 2, 3 }, { 0, 1, -0.5 }, { 0, 0, 1 } };
b = { { 2 }, { 0 }, { 1 } };
LsgX = { -0.5, 0.5, 1.0 };
for(size_t i = 0; i < 3; i++) { AssertEqual(x(i, 0), LsgX[i]); }
return true;
}
bool TestErrors() {
assert(x.rows() == 0);
assert(x2.rows() == 0);
assert(x2.columns() == 0);
return true;
}
public:
void run() override {
TestBackwardSub();
TestErrors();
}
};
int main() { BackwardSubTestCase().run(); }
Matrix< double > backwardSub(const Matrix< double > &R, const Matrix< double > &b)
Definition: backwardSub.h:27