Added simplify and differentiation tests

This commit is contained in:
maartenkeijzer 2005-10-11 08:15:29 +00:00
commit 72c8b3d1c5
4 changed files with 37 additions and 2 deletions

View file

@ -39,7 +39,7 @@ libsym.a: $(OBJS)
rm libsym.a; ar cq $(SYMLIB) $(OBJS)
check: $(TESTPROGRAMS)
test/test_compile && test/testeo && test_simplify && echo "all tests succeeded"
test/test_compile && test/testeo && test/test_simplify && test/test_diff && echo "all tests succeeded"
test/test_compile: test/test_compile.o ${SYMLIB}
$(CXX) -o test/test_compile test/test_compile.o $(SYMLIB) ${LIBS}

View file

@ -0,0 +1,17 @@
#include <Sym.h>
#include <FunDef.h>
#include <iostream>
using namespace std;
int main() {
Sym v = SymConst(1.2);
Sym g = exp(-sqr(v));
cout << g << endl;
cout << differentiate(g, v.token()) << endl;
}

View file

@ -0,0 +1,18 @@
#include <FunDef.h>
using namespace std;
int main() {
Sym c1 = SymConst(0.4);
Sym c2 = SymConst(0.3);
Sym v1 = SymVar(0);
Sym expr = (c1 + c2) * ( (c1 + c2) * v1);
cout << expr << endl;
cout << simplify(expr) << endl;
}

View file

@ -102,7 +102,7 @@ int main() {
cout << "****** Evaluation **********" << endl;
Dataset dataset;
dataset.load_data("problem4.dat");
dataset.load_data("test_data.txt");
IntervalBoundsCheck check(dataset.input_minima(), dataset.input_maxima());
ErrorMeasure measure(dataset, 0.90, ErrorMeasure::mean_squared_scaled);