File: SympyDummy.cc

package info (click to toggle)
cadabra2 2.4.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,796 kB
  • sloc: ansic: 133,450; cpp: 92,064; python: 1,530; javascript: 203; sh: 184; xml: 182; objc: 53; makefile: 51
file content (70 lines) | stat: -rw-r--r-- 1,958 bytes parent folder | download | duplicates (3)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

#include "Parser.hh"
#include "Cleanup.hh"
#include "PreClean.hh"
#include "SympyCdb.hh"
#include "DisplaySympy.hh"
#ifdef USE_TREETRACKER
#include "treetracker.h"
#endif
#include <sstream>

cadabra::Ex::iterator sympy::apply(const cadabra::Kernel& kernel, cadabra::Ex& ex, cadabra::Ex::iterator& it,
                                   const std::vector<std::string>& head, std::vector<std::string> args,
                                   const std::string& method)
	{
	std::ostringstream str;

	if(head.size()>0)
		str << head[0] << "(";

	cadabra::DisplaySympy ds(kernel, ex);
	ds.output(str, it);

	if(head.size()>0)
		if(args.size()>0)
			str << ", " << args[0] << ")";
	str << method;

	if(head.size()>0)
		str << ")";

	//	std::cerr << "Send: " << str.str() << std::endl;

#ifdef USE_TREETRACKER

	auto res = TreeTracker::FromString(str.str());
	res.RecursiveSimplify();
	std::stringstream istr;
	res.ShowTree(istr, 0, false, true);
	//	std::cerr << "Return: " << istr.str() << std::endl;
	auto ptr = std::make_shared<cadabra::Ex>();
	cadabra::Parser parser(ptr);
	istr >> parser;
	pre_clean_dispatch_deep(kernel, *parser.tree);
	cleanup_dispatch_deep(kernel, *parser.tree);
	//parser.tree->print_recursive_treeform(std::cerr, parser.tree->begin());
	ds.import(*parser.tree);

	cadabra::Ex::iterator first=parser.tree->begin();
	it = ex.move_ontop(it, first);
#endif

	return it;
	}

void sympy::invert_matrix(const cadabra::Kernel& kernel, cadabra::Ex& ex,
								  cadabra::Ex& rules, const cadabra::Ex& tocompute)
	{
	throw std::logic_error("Not implemented: sympy::invert_matrix");
	}

void sympy::determinant(const cadabra::Kernel&, cadabra::Ex& ex, cadabra::Ex& rules, const cadabra::Ex& tocompute)
	{
	throw std::logic_error("Not implemented: sympy::determinant");
	}

void sympy::trace(const cadabra::Kernel&, cadabra::Ex& ex, cadabra::Ex& rules, const cadabra::Ex& tocompute)
	{
	throw std::logic_error("Not implemented: sympy::trace");
	}