These are chat archives for symengine/symengine
Physicsmodule, at certain places I was unable to use
hbarconstant was being passed to them. Should I implement the same in
hbar = PyFunction(sympy.hbar, (), sympy.hbar.func, sympy_module)
uintpoly_piranha.hfor multivariate polynomials that accomplishes the SymPy --> Piranha conversion. What would be the analog to convert the other way?
piranha::polynomial, one gets pairs of (coefficient,
piranha::polynomial) where the second elements are the monomials. Do you know if there is a simple way to convert the
piranha::polynomials in those pairs to their corresponding collection of exponents? SymEngine must be doing it somewhere but I am not sure where.
ptr_->m_key.begin()to get the power of the variable
m_keyaccesses the Piranha exponents though. If I have
piranha::polynomial polyit seems I cannot call something like
poly._container().m_key. Sorry for all the questions.
poly._container().begin()gives an iterator with
m_cffor the monomial and the coefficient
poly._container().begin()->m_key.begin()should do it. Thanks!
it = poly._container().begin(); it != poly._container().end(); it++and then from
it2=it->m_key.begin(); it2!= it->m_key.end(); it2++
poly._container().begin()gives you access directly to the
piranha::termobjects contained in a piranha poly. Each term in turn contains two members,
poly.begin()gives you back a "fat" iterator, I'd recommend avoiding it for performance reasons
sympify, but yeah the conversion takes too long with that approach. Thanks for the clarification with iterating through terms - that's what I was looking for. Do you think using SymPy's
from_dict()along with iterating through
poly._container()will give good performance for he conversion or do you have a better way in mind? I was thinking of linking the Python and C++ with ctypes, though Cython, pybind11, and boost could be options too.
poly._container()gives you directly access to the internal hash table used to store the individual terms, so it's the fastest way to access the terms