diff --git a/examples/Makefile.am b/examples/Makefile.am index 34353ed..32daf83 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -15,15 +15,25 @@ endif endif noinst_PROGRAMS = \ - exMathInterpreter \ - exCompiledDoubleFunction - -exMathInterpreter_SOURCES = exMathInterpreter.cpp -exMathInterpreter_CFLAGS = -g -O2 -exMathInterpreter_LDFLAGS = -L../latan/.libs -llatan + exCompiledDoubleFunction\ + exMat \ + exMathInterpreter \ + exPlot exCompiledDoubleFunction_SOURCES = exCompiledDoubleFunction.cpp exCompiledDoubleFunction_CFLAGS = -g -O2 exCompiledDoubleFunction_LDFLAGS = -L../latan/.libs -llatan +exMat_SOURCES = exMat.cpp +exMat_CFLAGS = -g -O2 +exMat_LDFLAGS = -L../latan/.libs -llatan + +exMathInterpreter_SOURCES = exMathInterpreter.cpp +exMathInterpreter_CFLAGS = -g -O2 +exMathInterpreter_LDFLAGS = -L../latan/.libs -llatan + +exPlot_SOURCES = exPlot.cpp +exPlot_CFLAGS = -g -O2 +exPlot_LDFLAGS = -L../latan/.libs -llatan + ACLOCAL_AMFLAGS = -I .buildutils/m4 diff --git a/examples/exMat.cpp b/examples/exMat.cpp new file mode 100644 index 0000000..c347360 --- /dev/null +++ b/examples/exMat.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +using namespace std; +using namespace Latan; + +int main(void) +{ + AsciiFile F; + DMat A,B; + const string fileName = "exMat.dat"; + + // read + cout << "-- reading " << fileName << "..." << endl; + F.open(fileName, File::Mode::read); + A = F.read("A"); + B = F.read("B"); + cout << "A=\n" << A << '\n' << endl; + cout << "B=\n" << B << '\n' << endl; + cout << "A*B=\n" << A*B << '\n' << endl; + F.close(); + + // write + cout << "-- saving A*B..." << endl; + F.open(fileName, File::Mode::append); + F.save((A*B).eval(), "AB"); + + return EXIT_SUCCESS; +} diff --git a/examples/exMathInterpreter.cpp b/examples/exMathInterpreter.cpp index 42df050..aaf5417 100644 --- a/examples/exMathInterpreter.cpp +++ b/examples/exMathInterpreter.cpp @@ -41,35 +41,3 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } - -/*int main(void) -{ - ASCIIFile F; - DMat A,B; - - F.Open("foo.boot",FileMode::Read); - A = F.Read("bla"); - B = F.Read("bli"); - cout << A << endl; - cout << B << endl; - cout << A*B << endl; - - return EXIT_SUCCESS; -}*/ - -/* -int main(void) -{ - DMat m(2,2); - - m(0,6) = 3; - m(1,0) = 2.5; - m(0,1) = -1; - m(1,1) = m(1,0) + m(0,1); - cout << "Here is the matrix m:\n" << m << endl; - DVec v(2); - v(0) = 4; - v(1) = v(0) - 1; - cout << "Here is the vector v:\n" << v << endl; -} -*/ diff --git a/examples/exPlot.cpp b/examples/exPlot.cpp new file mode 100644 index 0000000..cd87c3d --- /dev/null +++ b/examples/exPlot.cpp @@ -0,0 +1,16 @@ +#include +#include + +using namespace std; +using namespace Latan; + +int main(void) +{ + Plot p; + + p << PlotCommand("x**2") << PlotCommand("x**3") << PlotCommand("x**4"); + cout << p << endl; + p.display(); + + return EXIT_SUCCESS; +} diff --git a/latan/MathInterpreter.hpp b/latan/MathInterpreter.hpp index 88f06ea..8ba26b3 100644 --- a/latan/MathInterpreter.hpp +++ b/latan/MathInterpreter.hpp @@ -34,7 +34,7 @@ BEGIN_NAMESPACE /****************************************************************************** - * Parser classes * + * Expression node class * ******************************************************************************/ class MathNode { @@ -191,7 +191,7 @@ DECL_OP(Div); DECL_OP(Pow); /****************************************************************************** - * Compiler class * + * Interpreter class * ******************************************************************************/ class MathInterpreter { diff --git a/latan/ParserState.hpp b/latan/ParserState.hpp index 7f687d0..f5b21d9 100644 --- a/latan/ParserState.hpp +++ b/latan/ParserState.hpp @@ -40,10 +40,10 @@ private: virtual void initScanner(void) = 0; virtual void destroyScanner(void) = 0; public: - DataObj* data; - void* scanner; - std::istream* stream; - std::string* streamName; + DataObj *data; + void *scanner; + std::istream *stream; + std::string *streamName; };