File: complete.cc

package info (click to toggle)
cadabra2 2.4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 78,732 kB
  • sloc: ansic: 133,450; cpp: 92,064; python: 1,530; javascript: 203; sh: 184; xml: 182; objc: 53; makefile: 51
file content (55 lines) | stat: -rw-r--r-- 1,259 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

#include "algorithms/complete.hh"
#include "Functional.hh"
#include "properties/Metric.hh"
#include "properties/InverseMetric.hh"
#include "properties/Determinant.hh"
#include "properties/Trace.hh"
#include "SympyCdb.hh"

using namespace cadabra;

complete::complete(const Kernel& k, Ex& e, Ex& g)
	: Algorithm(k, e), goal(g)
	{
	}

bool complete::can_apply(iterator )
	{
	return true;
	}

Algorithm::result_t complete::apply(iterator& )
	{
	result_t res=result_t::l_no_action;

	iterator bg=goal.begin();

	const InverseMetric *invmetric = kernel.properties.get<InverseMetric>(bg);
	if(invmetric) {
		Ex metric(bg);
		Ex::iterator ind1=metric.child(metric.begin(), 0);
		Ex::iterator ind2=metric.child(metric.begin(), 1);
		ind1->flip_parent_rel();
		ind2->flip_parent_rel();

		sympy::invert_matrix(kernel, metric, tr, bg);
		res = result_t::l_applied;
		}
	const Determinant *det = kernel.properties.get<Determinant>(bg);
	if(det) {
		Ex metric(det->obj);
		sympy::determinant(kernel, metric, tr, bg);
		res = result_t::l_applied;
		}
	const Trace *trace = kernel.properties.get<Trace>(bg);
	if(trace) {
		if(trace->obj.size()>0) {
			Ex metric(trace->obj);
			sympy::trace(kernel, metric, tr, bg);
			res = result_t::l_applied;
			}
		}

	return res;
	}