These are chat archives for symengine/symengine

8th
Nov 2015
Yet Another Minion
@YetAnotherMinion
Nov 08 2015 00:00
This message was deleted
This message was deleted
harakas
@harakas
Nov 08 2015 13:19
symengine.py. Is it as intended that DenseMatrix has no __sub__ and also adding or multiplying matrices of incompatible size results in a assert/crash in debug mode and silent memory corruption/crash in release mode? And Also I think that even in c++ it is overly easy to silently crash with DenseMatrix. I'd love to have my matrices to have sanity asserts on even in "Release" mode as matrix sizes are often not static in programs (for example this behaviour is the default in Eigen). I guess most of the vector algebra (dot, cross, norms, etc) are missing right now.
Isuru Fernando
@isuruf
Nov 08 2015 13:31
Can you open an issue in symengine.py repo for missing __sub__ method?
As for asserts, maybe we can have another CMake option just to enable Matrix bounds checks as enabling SYMENGINE_ASSERT results in crashes.
Isuru Fernando
@isuruf
Nov 08 2015 13:46
Btw, you can turn on asserts in Release mode by giving -DWITH_SYMENGINE_ASSERT=yes, but this will considerably slow down the program as assert checks are turned on throughout SymEngine
harakas
@harakas
Nov 08 2015 13:57
@isuruf, I opened symengine/symengine.py#17.
harakas
@harakas
Nov 08 2015 18:06
symengine.py: is it supposed to be possible to manually construct objects like Mul or Add? Say like Mul(x, y, z) or something? This works with sympy but not with symengine.py.
Isuru Fernando
@isuruf
Nov 08 2015 18:26
Nope. In symengine C++ library, Mul object has a specific format. It is a dictionary with a Basic mapping to a Number. This format is preserved and later used unlike SymPy which generates this type of mapping everytime a Mul object is formed and discards it after it is formed.
You can do this in Cython though. Let us know any use case where this might be useful
harakas
@harakas
Nov 08 2015 18:44
I'm looking at components of Mul, using the args property. And say decide I want to replace one of them with something else. I don't want to use subs() as it a) is slow and b) also works through the other subexpressions. Why am I doing all this? I'm doing code generation. Sympy got too slow for me so here I am.
Isuru Fernando
@isuruf
Nov 08 2015 18:59
Okay. Since you want performance I think writing this in Cython would be best. Although Python wrappers gives an args property, that's not how it is internally represented at SymEngine. Something like Mul(50, {x:x, y:5,z:1}) accurately represents a symengine object (50*x**x*y**5*z**1) and things like Mul(30, {x:x, 2*x:5, z:1}) will lead to errors.
Maybe an option for subs like deep=False would work?
harakas
@harakas
Nov 08 2015 19:39
I'm still figuring out the best way. Thanks for the tips.