#include "../../Test.h"
class MonomBaseTestCase : public Test
{
bool TestConstructor() {
AssertEqual(base.A, a);
X = { { -1, 0, 1, -1 } };
Y = { { 1 }, { 0 }, { 1 }, { 1 } };
AssertEqual(base2.
A.
rows(), 0);
return true;
}
bool TestEvaluate() {
auto res = base.Evaluate(xi);
AssertEqual(res, expected);
return true;
}
bool TestFunction() {
AssertEqual(base.Function(), "0 + 0x^1 + 1x^2");
return true;
}
public:
virtual void run() {
TestConstructor();
TestFunction();
TestEvaluate();
}
};
class LagrangeBaseTestCase : public Test
{
bool TestConstructor() {
return true;
}
bool TestEvaluate() {
int m = 5;
auto res = base.Evaluate(xi);
AssertEqual(res, expected);
return true;
}
bool TestFunction() {
AssertEqual(base.Function(), "1 * (-x/1.000 * -(x - 1.000)/2.000) + 1 * ((x + 1.000)/2.000 * x/1.000)");
return true;
}
public:
virtual void run() {
TestConstructor();
TestFunction();
TestEvaluate();
}
};
class NewtonBaseTestCase : public Test
{
bool TestConstructor() {
AssertEqual(base.b, expected);
return true;
}
bool TestEvaluate() {
AssertEqual(base.b, b);
auto res = base.Evaluate(xi);
AssertEqual(res, expected);
return true;
}
bool TestFunction() {
AssertEqual(base.Function(), "1.000 + -1.000* (x + 1.000) + 1.000* (x + 1.000)* x");
return true;
}
public:
virtual void run() {
TestConstructor();
TestFunction();
TestEvaluate();
}
};
int main() {
MonomBaseTestCase().run();
LagrangeBaseTestCase().run();
NewtonBaseTestCase().run();
return 0;
}
Definition: SupportValues.h:133
constexpr Matrix< T > Transpose() const
Definition: Matrix.h:256
size_t rows() const
Definition: Matrix.h:193
size_t columns() const
Definition: Matrix.h:198
Matrix< T > Apply(const std::function< T(T)> &fun) const
Definition: Matrix.h:375
Definition: SupportValues.h:69
Matrix< double > A
Coefficient matrix.
Definition: SupportValues.h:72
Definition: SupportValues.h:259
Matrix< double > linspace(double start, double end, unsigned long num_elements)