Cadabra
Computer algebra system for field theory problems
Classes | Functions | Variables
PythonCdb.cc File Reference
#include <memory>
#include "Config.hh"
#include "PythonCdb.hh"
#include "SympyCdb.hh"
#include "Parser.hh"
#include "Bridge.hh"
#include "Exceptions.hh"
#include "DisplayMMA.hh"
#include "DisplayTeX.hh"
#include "DisplaySympy.hh"
#include "DisplayTerminal.hh"
#include "Cleanup.hh"
#include "PreClean.hh"
#include "PythonException.hh"
#include "ProgressMonitor.hh"
#include <pybind11/pybind11.h>
#include <pybind11/embed.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include <boost/algorithm/string/replace.hpp>
#include <sstream>
#include "properties/Accent.hh"
#include "properties/AntiCommuting.hh"
#include "properties/AntiSymmetric.hh"
#include "properties/Commuting.hh"
#include "properties/Coordinate.hh"
#include "properties/Depends.hh"
#include "properties/DependsInherit.hh"
#include "properties/Derivative.hh"
#include "properties/DifferentialForm.hh"
#include "properties/DiracBar.hh"
#include "properties/GammaMatrix.hh"
#include "properties/CommutingAsProduct.hh"
#include "properties/CommutingAsSum.hh"
#include "properties/DAntiSymmetric.hh"
#include "properties/Diagonal.hh"
#include "properties/Distributable.hh"
#include "properties/EpsilonTensor.hh"
#include "properties/ExteriorDerivative.hh"
#include "properties/FilledTableau.hh"
#include "properties/ImaginaryI.hh"
#include "properties/ImplicitIndex.hh"
#include "properties/Indices.hh"
#include "properties/IndexInherit.hh"
#include "properties/Integer.hh"
#include "properties/InverseMetric.hh"
#include "properties/KroneckerDelta.hh"
#include "properties/LaTeXForm.hh"
#include "properties/Matrix.hh"
#include "properties/Metric.hh"
#include "properties/NonCommuting.hh"
#include "properties/NumericalFlat.hh"
#include "properties/PartialDerivative.hh"
#include "properties/RiemannTensor.hh"
#include "properties/SatisfiesBianchi.hh"
#include "properties/SelfAntiCommuting.hh"
#include "properties/SelfCommuting.hh"
#include "properties/SelfNonCommuting.hh"
#include "properties/SortOrder.hh"
#include "properties/Spinor.hh"
#include "properties/Symbol.hh"
#include "properties/Symmetric.hh"
#include "properties/Tableau.hh"
#include "properties/TableauSymmetry.hh"
#include "properties/Traceless.hh"
#include "properties/Vielbein.hh"
#include "properties/Weight.hh"
#include "properties/WeightInherit.hh"
#include "properties/WeylTensor.hh"
#include "algorithms/canonicalise.hh"
#include "algorithms/collect_components.hh"
#include "algorithms/collect_factors.hh"
#include "algorithms/collect_terms.hh"
#include "algorithms/combine.hh"
#include "algorithms/complete.hh"
#include "algorithms/decompose_product.hh"
#include "algorithms/distribute.hh"
#include "algorithms/drop_weight.hh"
#include "algorithms/einsteinify.hh"
#include "algorithms/eliminate_kronecker.hh"
#include "algorithms/eliminate_metric.hh"
#include "algorithms/epsilon_to_delta.hh"
#include "algorithms/evaluate.hh"
#include "algorithms/expand.hh"
#include "algorithms/expand_delta.hh"
#include "algorithms/expand_diracbar.hh"
#include "algorithms/expand_power.hh"
#include "algorithms/factor_in.hh"
#include "algorithms/factor_out.hh"
#include "algorithms/fierz.hh"
#include "algorithms/flatten_sum.hh"
#include "algorithms/indexsort.hh"
#include "algorithms/integrate_by_parts.hh"
#include "algorithms/join_gamma.hh"
#include "algorithms/keep_terms.hh"
#include "algorithms/lr_tensor.hh"
#include "algorithms/map_sympy.hh"
#include "algorithms/order.hh"
#include "algorithms/product_rule.hh"
#include "algorithms/reduce_delta.hh"
#include "algorithms/rename_dummies.hh"
#include "algorithms/simplify.hh"
#include "algorithms/sort_product.hh"
#include "algorithms/sort_spinors.hh"
#include "algorithms/sort_sum.hh"
#include "algorithms/split_gamma.hh"
#include "algorithms/split_index.hh"
#include "algorithms/substitute.hh"
#include "algorithms/sym.hh"
#include "algorithms/tab_dimension.hh"
#include "algorithms/take_match.hh"
#include "algorithms/replace_match.hh"
#include "algorithms/rewrite_indices.hh"
#include "algorithms/unwrap.hh"
#include "algorithms/vary.hh"
#include "algorithms/young_project.hh"
#include "algorithms/young_project_product.hh"
#include "algorithms/young_project_tensor.hh"

Classes

class  ExNode
 ExNode is a combination of an Ex::iterator and an interface which we can use to manipulate the data pointed to by this iterator. More...
 

Functions

pybind11::list ProgressMonitor_totals_helper (ProgressMonitor &self)
 
pybind11::list terms (std::shared_ptr< Ex > ex)
 
Ex lhs (std::shared_ptr< Ex > ex)
 
Ex rhs (std::shared_ptr< Ex > ex)
 
Ex Ex_getslice (std::shared_ptr< Ex > ex, pybind11::slice slice)
 
Ex Ex_getitem (Ex &ex, int index)
 
ExNode Ex_getitem_string (Ex &ex, std::string tag)
 
void Ex_setitem (Ex &ex, int index, Ex val)
 
size_t Ex_len (Ex &ex)
 
std::string Ex_head (Ex &ex)
 
pybind11::object Ex_mult (Ex &ex)
 
std::string Ex_str_ (std::shared_ptr< Ex > ex)
 Generate the Python str() and repr() representation of the Ex object. More...
 
std::string Ex_to_input (std::shared_ptr< Ex > ex)
 
std::string Ex_latex_ (std::shared_ptr< Ex > ex)
 The Python 'print' function always calls the 'str' member on objects to be printed. More...
 
std::string Ex_repr_ (std::shared_ptr< Ex > ex)
 
std::string Ex_to_Sympy_string (std::shared_ptr< Ex > ex)
 Similar to Ex_to_Sympy, but only producing a string which can be parsed by Sympy, instead of a full-fledged Sympy expression. More...
 
pybind11::object Ex_to_Sympy (std::shared_ptr< Ex > ex)
 Outputs a Cadabra 'Ex' as a Sympy expression. More...
 
std::string Ex_to_MMA (std::shared_ptr< Ex > ex, bool use_unicode)
 
pybind11::object get_locals ()
 
pybind11::object get_globals ()
 
std::shared_ptr< Exfetch_from_python (const std::string &nm)
 Fetch an Ex object from the Python side using its Python identifier. More...
 
bool __eq__Ex_Ex (std::shared_ptr< Ex > one, std::shared_ptr< Ex > other)
 Comparison operator for Ex objects in Python. More...
 
bool __eq__Ex_int (std::shared_ptr< Ex > one, int other)
 Comparison operator for Ex objects in Python. More...
 
std::shared_ptr< Exmake_Ex_from_string (const std::string &ex_, bool make_ref, Kernel *kernel)
 
std::shared_ptr< Exconstruct_Ex_from_string (const std::string &ex_)
 
std::shared_ptr< Exconstruct_Ex_from_string_2 (const std::string &ex_, bool add_ref)
 
std::shared_ptr< Exmake_Ex_from_int (int num, bool make_ref=true)
 
std::shared_ptr< Exconstruct_Ex_from_int (int num)
 
std::shared_ptr< Exconstruct_Ex_from_int_2 (int num, bool add_ref)
 
Ex operator+ (const Ex &ex1, const Ex &ex2)
 
Ex operator- (const Ex &ex1, const Ex &ex2)
 
std::string init_ipython ()
 
pybind11::list list_properties ()
 
std::string print_tree (Ex *ex)
 
Kernelget_kernel_from_scope ()
 Get a pointer to the currently visible kernel. More...
 
Kernelcreate_scope ()
 Setup of kernels in current scope, callable from Python. More...
 
Kernelcreate_scope_from_global ()
 
Kernelcreate_empty_scope ()
 
void inject_defaults (Kernel *k)
 Inject properties directly into the Kernel, even if the kernel is not yet on the Python stack (needed when we create a new local scope: in this case we create the kernel and pass it back to be turned into local cdbkernel by Python, but we want to populate the kernel with defaults before we hand it back). More...
 
template<class F >
std::shared_ptr< Exdispatch_base (std::shared_ptr< Ex > ex, F &algo, bool deep, bool repeat, unsigned int depth, bool pre_order)
 
std::shared_ptr< Exmap_sympy_wrapper (std::shared_ptr< Ex > ex, std::string head, pybind11::args args)
 
void call_post_process (Kernel &kernel, std::shared_ptr< Ex > ex)
 Run the post-process Python function (if defined) on the given expression. More...
 
template<class F >
std::shared_ptr< Exdispatch_ex (std::shared_ptr< Ex > ex, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename Arg1 >
std::shared_ptr< Exdispatch_ex (std::shared_ptr< Ex > ex, Arg1 arg, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename Arg1 >
std::shared_ptr< Exdispatch_ex_preorder (std::shared_ptr< Ex > ex, Arg1 arg, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename Arg1 , typename Arg2 >
std::shared_ptr< Exdispatch_ex (std::shared_ptr< Ex > ex, Arg1 arg1, Arg2 arg2, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename Arg1 , typename Arg2 , typename Arg3 >
std::shared_ptr< Exdispatch_ex (std::shared_ptr< Ex > ex, Arg1 arg1, Arg2 arg2, Arg3 arg3, bool deep, bool repeat, unsigned int depth)
 
template<class F >
void def_algo_1 (const std::string &name, pybind11::module &m)
 
template<class P >
void def_prop (pybind11::module &m)
 
 PYBIND11_MODULE (cadabra2, m)
 
std::string replace_all (std::string str, const std::string &old, const std::string &new_s)
 Replace all occurrences of a substring in the original string. More...
 

Variables

bool output_ipython =false
 
bool post_process_enabled =true
 
ProgressMonitorpm =0
 

Function Documentation

◆ construct_Ex_from_int()

std::shared_ptr<Ex> construct_Ex_from_int ( int  num)

◆ construct_Ex_from_int_2()

std::shared_ptr<Ex> construct_Ex_from_int_2 ( int  num,
bool  add_ref 
)

◆ construct_Ex_from_string()

std::shared_ptr<Ex> construct_Ex_from_string ( const std::string &  ex_)

◆ construct_Ex_from_string_2()

std::shared_ptr<Ex> construct_Ex_from_string_2 ( const std::string &  ex_,
bool  add_ref 
)

◆ create_empty_scope()

Kernel* create_empty_scope ( )

◆ create_scope_from_global()

Kernel* create_scope_from_global ( )

◆ def_algo_1()

template<class F >
void def_algo_1 ( const std::string &  name,
pybind11::module &  m 
)

◆ def_prop()

template<class P >
void def_prop ( pybind11::module &  m)

◆ dispatch_base()

template<class F >
std::shared_ptr<Ex> dispatch_base ( std::shared_ptr< Ex ex,
F &  algo,
bool  deep,
bool  repeat,
unsigned int  depth,
bool  pre_order 
)

◆ dispatch_ex() [1/4]

template<class F >
std::shared_ptr<Ex> dispatch_ex ( std::shared_ptr< Ex ex,
bool  deep,
bool  repeat,
unsigned int  depth 
)

◆ dispatch_ex() [2/4]

template<class F , typename Arg1 >
std::shared_ptr<Ex> dispatch_ex ( std::shared_ptr< Ex ex,
Arg1  arg,
bool  deep,
bool  repeat,
unsigned int  depth 
)

◆ dispatch_ex() [3/4]

template<class F , typename Arg1 , typename Arg2 >
std::shared_ptr<Ex> dispatch_ex ( std::shared_ptr< Ex ex,
Arg1  arg1,
Arg2  arg2,
bool  deep,
bool  repeat,
unsigned int  depth 
)

◆ dispatch_ex() [4/4]

template<class F , typename Arg1 , typename Arg2 , typename Arg3 >
std::shared_ptr<Ex> dispatch_ex ( std::shared_ptr< Ex ex,
Arg1  arg1,
Arg2  arg2,
Arg3  arg3,
bool  deep,
bool  repeat,
unsigned int  depth 
)

◆ dispatch_ex_preorder()

template<class F , typename Arg1 >
std::shared_ptr<Ex> dispatch_ex_preorder ( std::shared_ptr< Ex ex,
Arg1  arg,
bool  deep,
bool  repeat,
unsigned int  depth 
)

◆ Ex_getitem()

Ex Ex_getitem ( Ex ex,
int  index 
)

◆ Ex_getitem_string()

ExNode Ex_getitem_string ( Ex ex,
std::string  tag 
)

◆ Ex_getslice()

Ex Ex_getslice ( std::shared_ptr< Ex ex,
pybind11::slice  slice 
)

◆ Ex_head()

std::string Ex_head ( Ex ex)

◆ Ex_len()

size_t Ex_len ( Ex ex)

◆ Ex_mult()

pybind11::object Ex_mult ( Ex ex)

◆ Ex_repr_()

std::string Ex_repr_ ( std::shared_ptr< Ex ex)

◆ Ex_setitem()

void Ex_setitem ( Ex ex,
int  index,
Ex  val 
)

◆ Ex_to_input()

std::string Ex_to_input ( std::shared_ptr< Ex ex)

◆ Ex_to_MMA()

std::string Ex_to_MMA ( std::shared_ptr< Ex ex,
bool  use_unicode 
)

◆ Ex_to_Sympy_string()

std::string Ex_to_Sympy_string ( std::shared_ptr< cadabra::Ex )

Similar to Ex_to_Sympy, but only producing a string which can be parsed by Sympy, instead of a full-fledged Sympy expression.

◆ fetch_from_python()

std::shared_ptr<Ex> fetch_from_python ( const std::string &  nm)

Fetch an Ex object from the Python side using its Python identifier.

◆ get_globals()

pybind11::object get_globals ( )

◆ get_locals()

pybind11::object get_locals ( )

◆ init_ipython()

std::string init_ipython ( )

◆ lhs()

Ex lhs ( std::shared_ptr< Ex ex)

◆ list_properties()

pybind11::list list_properties ( )

◆ make_Ex_from_int()

std::shared_ptr<Ex> make_Ex_from_int ( int  num,
bool  make_ref = true 
)

◆ make_Ex_from_string()

std::shared_ptr<Ex> make_Ex_from_string ( const std::string &  ex_,
bool  make_ref,
Kernel kernel 
)

◆ map_sympy_wrapper()

std::shared_ptr<Ex> map_sympy_wrapper ( std::shared_ptr< Ex ex,
std::string  head,
pybind11::args  args 
)

◆ operator+()

Ex operator+ ( const Ex ex1,
const Ex ex2 
)

◆ operator-()

Ex operator- ( const Ex ex1,
const Ex ex2 
)

◆ print_tree()

std::string print_tree ( Ex ex)

◆ ProgressMonitor_totals_helper()

pybind11::list ProgressMonitor_totals_helper ( ProgressMonitor self)

◆ PYBIND11_MODULE()

PYBIND11_MODULE ( cadabra2  ,
 
)

◆ replace_all()

std::string replace_all ( std::string  str,
const std::string &  old,
const std::string &  new_s 
)

Replace all occurrences of a substring in the original string.

◆ rhs()

Ex rhs ( std::shared_ptr< Ex ex)

◆ terms()

pybind11::list terms ( std::shared_ptr< Ex ex)

Variable Documentation

◆ output_ipython

bool output_ipython =false

◆ pm

◆ post_process_enabled

bool post_process_enabled =true