Cadabra
Computer algebra system for field theory problems
Functions
Scalar algebra

Module Description

Functionality to make Cadabra interface with scalar computer algebra systems such as Sympy or Mathematica. It converts scalar parts of Cadabra expressions ('things without indices') to one of these systems, runs them through, and then converts back to Cadabra notation. Currently available are SymPy and Mathematica backends.

Functions

static cadabra::Ex::iterator MMA::apply_mma (const cadabra::Kernel &, cadabra::Ex &, cadabra::Ex::iterator &, const std::vector< std::string > &wrap, std::vector< std::string > args, const std::string &method)
 
cadabra::Ex::iterator sympy::apply (const cadabra::Kernel &, cadabra::Ex &, cadabra::Ex::iterator &, const std::vector< std::string > &wrap, std::vector< std::string > args, const std::string &method)
 
void sympy::invert_matrix (const cadabra::Kernel &, cadabra::Ex &ex, cadabra::Ex &rules, const cadabra::Ex &tocompute)
 
void sympy::determinant (const cadabra::Kernel &, cadabra::Ex &ex, cadabra::Ex &rules, const cadabra::Ex &tocompute)
 
pybind11::object cadabra::Ex_as_sympy (Ex_ptr ex)
 

Function Documentation

◆ apply()

cadabra::Ex::iterator sympy::apply ( const cadabra::Kernel kernel,
cadabra::Ex ex,
cadabra::Ex::iterator &  it,
const std::vector< std::string > &  wrap,
std::vector< std::string >  args,
const std::string &  method 
)

Functionality to act with Sympy on all scalar parts of an expression, and keep the result in-place. This is a higher-level function than 'apply' below.

Functionality to act with Sympy functions on (parts of) Cadabra Ex expressions and read the result back into the same Ex. This duplicates some of the logic in PythonCdb.hh, in particular make_Ex_from_string, but it is best to keep these two completely separate.

◆ apply_mma()

Ex::iterator MMA::apply_mma ( const cadabra::Kernel ,
cadabra::Ex ,
cadabra::Ex::iterator &  ,
const std::vector< std::string > &  wrap,
std::vector< std::string >  args,
const std::string &  method 
)
static

Functionality to act with Mathematica functions on (parts of) Cadabra Ex expressions and read the result back into the same Ex. This duplicates some of the logic in PythonCdb.hh, in particular make_Ex_from_string, but it is best to keep these two completely separate.

◆ determinant()

void sympy::determinant ( const cadabra::Kernel kernel,
cadabra::Ex ex,
cadabra::Ex rules,
const cadabra::Ex tocompute 
)

Use Sympy to compute the determinant of a matrix, given a set of rules determining its sparse components. Will add the rules to the list.

◆ Ex_as_sympy()

pybind11::object cadabra::Ex_as_sympy ( Ex_ptr  )

Outputs a Cadabra 'Ex' as a Sympy expression. This first converts the Cadabra expression to a string, and then reads that back in by calling sympy.parsing.sympy_parser.parse_expr. Is mapped to a 'sympy()' function on each Ex object. When you feed an Ex object to a Sympy function, the Ex gets converted to a Sympy object in 'sympy.sympify' because the latter attempts to call sympy on every object that you feed it.

◆ invert_matrix()

void sympy::invert_matrix ( const cadabra::Kernel kernel,
cadabra::Ex ex,
cadabra::Ex rules,
const cadabra::Ex tocompute 
)

Use Sympy to invert a matrix, given a set of rules determining its sparse components. Will return a set of Cadabra rules for the inverse matrix.