1 #include "py_algorithms.hh"
2 
3 #include <pybind11/stl.h>
4 
5 #include "../Algorithm.hh"
6 
7 #include "../algorithms/canonicalise.hh"
8 #include "../algorithms/collect_components.hh"
9 #include "../algorithms/collect_factors.hh"
10 #include "../algorithms/collect_terms.hh"
11 #include "../algorithms/combine.hh"
12 #include "../algorithms/complete.hh"
13 #include "../algorithms/decompose.hh"
14 #include "../algorithms/decompose_product.hh"
15 #include "../algorithms/distribute.hh"
16 #include "../algorithms/drop_weight.hh"
17 #include "../algorithms/einsteinify.hh"
18 #include "../algorithms/eliminate_kronecker.hh"
19 #include "../algorithms/eliminate_metric.hh"
20 #include "../algorithms/eliminate_vielbein.hh"
21 #include "../algorithms/epsilon_to_delta.hh"
22 #include "../algorithms/evaluate.hh"
23 #include "../algorithms/expand.hh"
24 #include "../algorithms/expand_delta.hh"
25 #include "../algorithms/expand_diracbar.hh"
26 #include "../algorithms/expand_power.hh"
27 #include "../algorithms/explicit_indices.hh"
28 #include "../algorithms/factor_in.hh"
29 #include "../algorithms/factor_out.hh"
30 #include "../algorithms/fierz.hh"
31 #include "../algorithms/flatten_sum.hh"
32 #include "../algorithms/indexsort.hh"
33 #include "../algorithms/integrate_by_parts.hh"
34 #include "../algorithms/join_gamma.hh"
35 #include "../algorithms/keep_terms.hh"
36 #include "../algorithms/lower_free_indices.hh"
37 #include "../algorithms/lr_tensor.hh"
38 #ifdef MATHEMATICA_FOUND
39 #include "../algorithms/map_mma.hh"
40 #endif
41 #include "../algorithms/map_sympy.hh"
42 #include "../algorithms/meld.hh"
43 #include "../algorithms/order.hh"
44 #include "../algorithms/product_rule.hh"
45 #include "../algorithms/reduce_delta.hh"
46 #include "../algorithms/rename_dummies.hh"
47 #include "../algorithms/replace_match.hh"
48 #include "../algorithms/rewrite_indices.hh"
49 #include "../algorithms/simplify.hh"
50 #include "../algorithms/sort_product.hh"
51 #include "../algorithms/sort_spinors.hh"
52 #include "../algorithms/sort_sum.hh"
53 #include "../algorithms/split_gamma.hh"
54 #include "../algorithms/split_index.hh"
55 #include "../algorithms/substitute.hh"
56 #include "../algorithms/sym.hh"
57 #include "../algorithms/tab_dimension.hh"
58 #include "../algorithms/take_match.hh"
59 #include "../algorithms/unwrap.hh"
60 #include "../algorithms/unzoom.hh"
61 #include "../algorithms/untrace.hh"
62 #include "../algorithms/vary.hh"
63 #include "../algorithms/young_project.hh"
64 #include "../algorithms/young_project_product.hh"
65 #include "../algorithms/young_project_tensor.hh"
66 #include "../algorithms/zoom.hh"
67 
68 namespace cadabra {
69 	namespace py = pybind11;
70 
init_algorithms(py::module & m)71 	void init_algorithms(py::module& m)
72 		{
73 		pybind11::enum_<Algorithm::result_t>(m, "result_t")
74 		.value("checkpointed", Algorithm::result_t::l_checkpointed)
75 		.value("changed", Algorithm::result_t::l_applied)
76 		.value("unchanged", Algorithm::result_t::l_no_action)
77 		.value("error", Algorithm::result_t::l_error)
78 		.export_values();
79 
80 		def_algo<canonicalise>(m, "canonicalise", true, false, 0);
81 		def_algo<collect_components>(m, "collect_components", true, false, 0);
82 		def_algo<collect_factors>(m, "collect_factors", true, false, 0);
83 		def_algo<collect_terms>(m, "collect_terms", true, false, 0);
84 		def_algo<decompose_product>(m, "decompose_product", true, false, 0);
85 		def_algo<distribute>(m, "distribute", true, false, 0);
86 		def_algo<eliminate_kronecker>(m, "eliminate_kronecker", true, false, 0);
87 		def_algo<expand>(m, "expand", true, false, 0);
88 		def_algo<expand_delta>(m, "expand_delta", true, false, 0);
89 		def_algo<expand_diracbar>(m, "expand_diracbar", true, false, 0);
90 		def_algo<expand_power>(m, "expand_power", true, false, 0);
91 		def_algo<explicit_indices>(m, "explicit_indices", true, false, 0);
92 		def_algo<flatten_sum>(m, "flatten_sum", true, false, 0);
93 		def_algo<indexsort>(m, "indexsort", true, false, 0);
94 		def_algo<lr_tensor>(m, "lr_tensor", true, false, 0);
95 		def_algo<product_rule>(m, "product_rule", true, false, 0);
96 		def_algo<reduce_delta>(m, "reduce_delta", true, false, 0);
97 		def_algo<sort_product>(m, "sort_product", true, false, 0);
98 		def_algo<sort_spinors>(m, "sort_spinors", true, false, 0);
99 		def_algo<sort_sum>(m, "sort_sum", true, false, 0);
100 		def_algo<tabdimension>(m, "tab_dimension", true, false, 0);
101 		def_algo<young_project_product>(m, "young_project_product", true, false, 0);
102 		def_algo<combine, Ex>(m, "combine", true, false, 0, py::arg("trace_op") = Ex{});
103 		def_algo<complete, Ex>(m, "complete", false, false, 0, py::arg("add"));
104 		def_algo<decompose, Ex>(m, "decompose", false, false, 0, py::arg("basis"));
105 		def_algo<drop_weight, Ex>(m, "drop_weight", false, false, 0, py::arg("condition") = Ex{});
106 		def_algo<eliminate_metric, Ex,bool>(m, "eliminate_metric", true, false, 0, py::arg("preferred") = Ex{}, py::arg("redundant") = false);
107 		def_algo<eliminate_vielbein, Ex,bool>(m, "eliminate_vielbein", true, false, 0, py::arg("preferred") = Ex{},py::arg("redundant")= false);
108 		def_algo<keep_weight, Ex>(m, "keep_weight", false, false, 0, py::arg("condition"));
109 		def_algo<lower_free_indices, bool>(m, "lower_free_indices", true, false, 0, py::arg("lower") = true);
110 		def_algo<lower_free_indices, bool>(m, "raise_free_indices", true, false, 0, py::arg("lower") = false);
111 		def_algo<integrate_by_parts, Ex>(m, "integrate_by_parts", true, false, 0, py::arg("away_from"));
112 		def_algo<young_project_tensor, bool>(m, "young_project_tensor", true, false, 0, py::arg("modulo_monoterm") = false);
113 		def_algo<join_gamma, bool, bool>(m, "join_gamma", true, false, 0, py::arg("expand") = true, py::arg("use_gendelta") = false);
114 		def_algo<einsteinify, Ex>(m, "einsteinify", true, false, 0, py::arg("metric") = Ex{});
115 		def_algo<evaluate, Ex, bool, bool>(m, "evaluate", false, false, 0, py::arg("components") = Ex{}, py::arg("rhsonly") = false, py::arg("simplify") = true);
116 		def_algo<keep_terms, std::vector<int>>(m, "keep_terms", true, false, 0, py::arg("terms"));
117 		def_algo<young_project, std::vector<int>, std::vector<int>>(m, "young_project", true, false, 0, py::arg("shape"), py::arg("indices"));
118 		def_algo<simplify>(m, "simplify", false, false, 0);
119 		def_algo<order, Ex, bool>(m, "order", true, false, 0, py::arg("factors"), py::arg("anticommuting") = false);
120 		def_algo<epsilon_to_delta, bool>(m, "epsilon_to_delta", true, false, 0, py::arg("reduce") = true);
121 		def_algo<rename_dummies, std::string, std::string>(m, "rename_dummies", true, false, 0, py::arg("set") = "", py::arg("to") = "");
122 		def_algo<sym, Ex, bool>(m, "sym", true, false, 0, py::arg("items"), py::arg("antisymmetric") = false);
123 		def_algo<sym, Ex, bool>(m, "asym", true, false, 0, py::arg("items"), py::arg("antisymmetric") = true);
124 		def_algo<sym, std::vector<unsigned int>, bool>(m, "slot_sym", true, false, 0, py::arg("items"), py::arg("antisymmetric") = false);
125 		def_algo<sym, std::vector<unsigned int>, bool>(m, "slot_asym", true, false, 0, py::arg("items"), py::arg("antisymmetric") = true);
126 		def_algo<factor_in, Ex>(m, "factor_in", true, false, 0, py::arg("factors"));
127 		def_algo<factor_out, Ex, bool>(m, "factor_out", true, false, 0, py::arg("factors"), py::arg("right") = false);
128 		def_algo<fierz, Ex>(m, "fierz", true, false, 0, py::arg("spinors"));
129 		def_algo<substitute, Ex, bool>(m, "substitute", true, false, 0, py::arg("rules"), py::arg("partial") = true);
130 		def_algo<take_match, Ex>(m, "take_match", true, false, 0, py::arg("rules"));
131 		def_algo<replace_match>(m, "replace_match", false, false, 0);
132 		def_algo<zoom, Ex>(m, "zoom", true, false, 0, py::arg("rules"));
133 		def_algo_preorder<unzoom>(m, "unzoom", true, false, 0);
134 		def_algo<untrace>(m, "untrace", true, false, 0);
135 		def_algo<rewrite_indices, Ex, Ex>(m, "rewrite_indices", true, false, 0, py::arg("preferred"), py::arg("converters"));
136 		def_algo_preorder<vary, Ex>(m, "vary", false, false, 0, py::arg("rules"));
137 		def_algo<split_gamma, bool>(m, "split_gamma", true, false, 0, py::arg("on_back"));
138 		def_algo<split_index, Ex>(m, "split_index", true, false, 0, py::arg("rules"));
139 		def_algo<unwrap, Ex>(m, "unwrap", true, false, 0, py::arg("wrapper") = Ex{});
140 //		def_algo_preorder<young_reduce, const Ex*>(m, "young_reduce", true, false, 0, py::arg("pattern") = nullptr);
141 //		def_algo_preorder<young_reduce_trace>(m, "young_reduce_trace", true, false, 0);
142 		def_algo_preorder<meld>(m, "meld", true, false, 0);
143 		}
144 	}
145