File: calculator.cpp

package info (click to toggle)
dmrgpp 6.06-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 113,900 kB
  • sloc: cpp: 80,986; perl: 14,772; ansic: 2,923; makefile: 83; sh: 17
file content (28 lines) | stat: -rw-r--r-- 769 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "AST/ExpressionForAST.h"
#include "AST/PlusMinusMultiplyDivide.h"
#include "PredicateAwesome.h"
#include "PsimagLite.h"

#ifdef USE_COMPLEX
typedef std::complex<double> ComplexOrRealType;
#else
typedef double ComplexOrRealType;
#endif

int main(int argc, char** argv)
{
	if (argc < 2)
		return 1;

	typedef PsimagLite::Vector<PsimagLite::String>::Type VectorStringType;
	typedef PsimagLite::PlusMinusMultiplyDivide<ComplexOrRealType> PrimitivesType;
	PsimagLite::String str(argv[1]);
	PsimagLite::replaceAll(str, "%t", "0.25");
	VectorStringType ve;
	PsimagLite::split(ve, str, ":");

	PrimitivesType primitives;
	PsimagLite::ExpressionForAST<PrimitivesType> expresionForAST(ve, primitives);

	std::cout << argv[1] << "\t" << expresionForAST.exec() << "\n";
}