Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <boost/python/implicit.hpp>
#include <boost/parameter/preprocessor.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/python/enum.hpp>
#include <boost/python/def.hpp>
#include <boost/python/module.hpp>
#include <boost/python/stl_iterator.hpp>
#include <boost/python/slice.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#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/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/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/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  iterable_converter
 

Functions

template<typename T >
std::vector< T > to_std_vector (const boost::python::list &iterable)
 
boost::python::list ProgressMonitor_totals_helper (ProgressMonitor &self)
 
boost::python::list terms (const Ex &ex)
 
Ex lhs (const Ex &ex)
 
Ex rhs (const Ex &ex)
 
Ex Ex_getslice (Ex &ex, boost::python::slice slice)
 
Ex Ex_getitem (Ex &ex, int index)
 
void Ex_setitem (Ex &ex, int index, Ex val)
 
size_t Ex_len (Ex &ex)
 
std::string Ex_str_ (const Ex &ex)
 Generate the Python str() and repr() representation of the Ex object. More...
 
std::string Ex_to_input (const Ex &ex)
 
std::string Ex_latex_ (const Ex &ex)
 The Python 'print' function always calls the 'str' member on objects to be printed. More...
 
std::string Ex_repr_ (const Ex &ex)
 
std::string Ex_to_Sympy_string (const 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...
 
boost::python::object Ex_to_Sympy (const Ex &ex)
 Outputs a Cadabra 'Ex' as a Sympy expression. More...
 
std::string Ex_to_MMA (const Ex &ex, bool use_unicode)
 
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 (const Ex &one, const Ex &other)
 Comparison operator for Ex objects in Python. More...
 
bool __eq__Ex_int (const 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=true)
 
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)
 Add two expressions, adding a top-level node if required. More...
 
Ex operator- (const Ex &ex1, const Ex &ex2)
 Subtract two expressions, adding a top-level node if required. More...
 
std::string init_ipython ()
 
boost::python::list list_properties ()
 
std::string print_tree (Ex *ex)
 
PyObject * createExceptionClass (const char *name, PyObject *baseTypeObj=PyExc_Exception)
 
void translate_ArgumentException (const ArgumentException &x)
 
void translate_ConsistencyException (const ConsistencyException &x)
 
void translate_ParseException (const ParseException &e)
 
void translate_RuntimeException (const RuntimeException &e)
 
void translate_NonScalarException (const NonScalarException &e)
 
void translate_InternalError (const InternalError &e)
 
void translate_NotYetImplemented (const NotYetImplemented &e)
 
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 >
Exdispatch_base (Ex &ex, F &algo, bool deep, bool repeat, unsigned int depth, bool pre_order)
 
Exmap_sympy_wrapper (Ex &ex, std::string head)
 
void call_post_process (Kernel &kernel, Ex &ex)
 Run the post-process Python function (if defined) on the given expression. More...
 
template<class F >
Exdispatch_ex (Ex &ex, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename Arg1 >
Exdispatch_ex (Ex &ex, Arg1 arg, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename Arg1 , typename Arg2 >
Exdispatch_ex (Ex &ex, Arg1 arg1, Arg2 arg2, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename Arg1 , typename Arg2 , typename Arg3 >
Exdispatch_ex (Ex &ex, Arg1 arg1, Arg2 arg2, Arg3 arg3, bool deep, bool repeat, unsigned int depth)
 
template<class F , typename... Args>
Exdispatch_string (const std::string &ex, Args...args, bool deep, bool repeat, unsigned int depth)
 
template<class F >
void def_algo_1 (const std::string &name)
 
template<class P >
void def_prop ()
 
 BOOST_PYTHON_MODULE (cadabra2)
 

Variables

bool output_ipython =false
 
bool post_process_enabled =true
 
PyObject * ParseExceptionType = NULL
 
PyObject * ArgumentExceptionType = 0
 
PyObject * ConsistencyExceptionType = 0
 
PyObject * RuntimeExceptionType = 0
 
PyObject * NonScalarExceptionType = NULL
 
PyObject * InternalErrorType = NULL
 
PyObject * NotYetImplementedType = NULL
 
ProgressMonitorpm =0
 

Function Documentation

BOOST_PYTHON_MODULE ( cadabra2  )
std::shared_ptr<Ex> construct_Ex_from_int ( int  num)
std::shared_ptr<Ex> construct_Ex_from_int_2 ( int  num,
bool  add_ref 
)
std::shared_ptr<Ex> construct_Ex_from_string ( const std::string &  ex_)
std::shared_ptr<Ex> construct_Ex_from_string_2 ( const std::string &  ex_,
bool  add_ref 
)
Kernel* create_empty_scope ( )
Kernel* create_scope_from_global ( )
PyObject* createExceptionClass ( const char *  name,
PyObject *  baseTypeObj = PyExc_Exception 
)
template<class F >
void def_algo_1 ( const std::string &  name)
template<class P >
void def_prop ( )
template<class F >
Ex* dispatch_base ( Ex ex,
F &  algo,
bool  deep,
bool  repeat,
unsigned int  depth,
bool  pre_order 
)
template<class F >
Ex* dispatch_ex ( Ex ex,
bool  deep,
bool  repeat,
unsigned int  depth 
)
template<class F , typename Arg1 >
Ex* dispatch_ex ( Ex ex,
Arg1  arg,
bool  deep,
bool  repeat,
unsigned int  depth 
)
template<class F , typename Arg1 , typename Arg2 >
Ex* dispatch_ex ( Ex ex,
Arg1  arg1,
Arg2  arg2,
bool  deep,
bool  repeat,
unsigned int  depth 
)
template<class F , typename Arg1 , typename Arg2 , typename Arg3 >
Ex* dispatch_ex ( Ex ex,
Arg1  arg1,
Arg2  arg2,
Arg3  arg3,
bool  deep,
bool  repeat,
unsigned int  depth 
)
template<class F , typename... Args>
Ex* dispatch_string ( const std::string &  ex,
Args...  args,
bool  deep,
bool  repeat,
unsigned int  depth 
)
Ex Ex_getitem ( Ex ex,
int  index 
)
Ex Ex_getslice ( Ex ex,
boost::python::slice  slice 
)
size_t Ex_len ( Ex ex)
std::string Ex_repr_ ( const Ex ex)
void Ex_setitem ( Ex ex,
int  index,
Ex  val 
)
std::string Ex_to_input ( const Ex ex)
std::string Ex_to_MMA ( const Ex ex,
bool  use_unicode 
)
std::string Ex_to_Sympy_string ( const 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.

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

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

std::string init_ipython ( )
Ex lhs ( const Ex ex)
boost::python::list list_properties ( )
std::shared_ptr<Ex> make_Ex_from_int ( int  num,
bool  make_ref = true 
)
std::shared_ptr<Ex> make_Ex_from_string ( const std::string &  ex_,
bool  make_ref = true 
)
Ex* map_sympy_wrapper ( Ex ex,
std::string  head 
)
std::string print_tree ( Ex ex)
boost::python::list ProgressMonitor_totals_helper ( ProgressMonitor self)
Ex rhs ( const Ex ex)
boost::python::list terms ( const Ex ex)
template<typename T >
std::vector<T> to_std_vector ( const boost::python::list &  iterable)
void translate_ArgumentException ( const ArgumentException x)
void translate_ConsistencyException ( const ConsistencyException x)
void translate_InternalError ( const InternalError e)
void translate_NonScalarException ( const NonScalarException e)
void translate_NotYetImplemented ( const NotYetImplemented e)
void translate_ParseException ( const ParseException e)
void translate_RuntimeException ( const RuntimeException e)

Variable Documentation

PyObject* ArgumentExceptionType = 0
PyObject* ConsistencyExceptionType = 0
PyObject* InternalErrorType = NULL
PyObject* NonScalarExceptionType = NULL
PyObject* NotYetImplementedType = NULL
bool output_ipython =false
PyObject* ParseExceptionType = NULL
bool post_process_enabled =true
PyObject* RuntimeExceptionType = 0