1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00

minor code cleaning and examples update

This commit is contained in:
Antonin Portelli 2014-02-10 11:22:56 +00:00
parent db61c7ea90
commit 84d063edf0
6 changed files with 68 additions and 44 deletions

View File

@ -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

30
examples/exMat.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <iostream>
#include <latan/Io.hpp>
#include <latan/Mat.hpp>
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<DMat>("A");
B = F.read<DMat>("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;
}

View File

@ -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<DMat>("bla");
B = F.Read<DMat>("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;
}
*/

16
examples/exPlot.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <iostream>
#include <latan/Plot.hpp>
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;
}

View File

@ -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
{

View File

@ -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;
};