mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-06-19 07:47:05 +01:00
big cleaning and update: switching to C++11
This commit is contained in:
@ -17,10 +17,10 @@ int main(void)
|
||||
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;
|
||||
cout << "cos(A)=\n" << A.unaryExpr(StdMath::cos) << '\n' << endl;
|
||||
cout << "A=\n" << A << '\n' << endl;
|
||||
cout << "B=\n" << B << '\n' << endl;
|
||||
cout << "A*B=\n" << A*B << '\n' << endl;
|
||||
cout << "cos(A)=\n" << A.unaryExpr(StdMath::cos) << '\n' << endl;
|
||||
F.close();
|
||||
|
||||
// write
|
||||
|
20
examples/exMat.dat
Normal file
20
examples/exMat.dat
Normal file
@ -0,0 +1,20 @@
|
||||
#L latan_begin mat A
|
||||
2
|
||||
2.3 5
|
||||
4.5 -1.15281
|
||||
#L latan_end mat
|
||||
|
||||
#L latan_begin mat B
|
||||
3
|
||||
1.1
|
||||
1.2
|
||||
1.3
|
||||
2
|
||||
2.2
|
||||
2.3
|
||||
#L latan_end mat
|
||||
#L latan_begin mat AB
|
||||
3
|
||||
12.53 13.76 14.49
|
||||
2.64438 2.86382 3.19854
|
||||
#L latan_end mat
|
@ -1,70 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <latan/Math.hpp>
|
||||
#include <latan/MathCompiler.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace Latan;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
string source;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
cerr << "usage: " << argv[0] << " <program>" << endl;
|
||||
}
|
||||
source = argv[1];
|
||||
|
||||
MathCompiler C(source);
|
||||
VarTable vtable;
|
||||
FunctionTable ftable;
|
||||
stack<double> dstack;
|
||||
const VirtualProgram& P = C();
|
||||
|
||||
cout << "-- Source code:" << endl << source << endl << endl;
|
||||
cout << "-- Abstract Syntax Tree:" << endl << *C.getAST() << endl;
|
||||
cout << "-- Program:" << endl << P << endl;
|
||||
StdMath::addStdMathFunc(ftable);
|
||||
for (unsigned int i=0;i<P.size();++i)
|
||||
{
|
||||
(*(P[i]))(dstack, vtable, ftable);
|
||||
}
|
||||
if (!dstack.empty())
|
||||
{
|
||||
cout << "-- Result: " << dstack.top() << endl;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user