Added simplify and differentiation tests
This commit is contained in:
parent
89b76ab261
commit
72c8b3d1c5
4 changed files with 37 additions and 2 deletions
|
|
@ -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}
|
||||
|
|
|
|||
17
eo/contrib/mathsym/test/test_diff.cpp
Normal file
17
eo/contrib/mathsym/test/test_diff.cpp
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
18
eo/contrib/mathsym/test/test_simplify.cpp
Normal file
18
eo/contrib/mathsym/test/test_simplify.cpp
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue