lkeegan on master
Add LambdaRealDoubleVisitor cse… Delete copy constructor of Lamb… Capture a pointer to cse_interm… and 1 more (compare)
cmake -DCMAKE_INSTALL_PREFIX=$HOME/git/symengine/build -DINTEGER_CLASS=boostmp -DWITH_LLVM=8.0 -DWITH_OPENMP=yes .
cmake -DSymEngine_DIR=$HOME/git/symengine/build . && make
pip install -e .
to make symengine.py available to conda. Everything was built using my system gcc
Hello there. Thanks for your awesome library.
Please have a look to this:
#include <symengine/expression.h>
int main(int argc, char* argv[]) {
auto x = SymEngine::symbol("x");
std::cout << "#1: " << SymEngine::Expression(SymEngine::abs(SymEngine::abs(x))) << "\n";
std::cout << "#2: " << SymEngine::Expression(SymEngine::abs(SymEngine::mul(x, SymEngine::sign(x)))) << "\n";
std::cout << "#3: " << SymEngine::Expression(SymEngine::floor(SymEngine::ceiling(x))) << "\n";
std::cout << "#4: " << SymEngine::Expression(SymEngine::ceiling(SymEngine::floor(x))) << "\n";
return 0;
}
Output:
#1: abs(abs(x))
#2: abs(x*sign(x))
#3: ceiling(x)
#4: floor(x)
Maybe I'm doing something wrong, but I'd expect #1 = #2 = abs(x)
What do you think about that?
@isuruf thank you very much. To be honest I wouldn't even need the second one if the truncate function (aka static_cast<int>) was implemented. In fact, as a temporary solution, I solved it using
SymEngine::mul(SymEngine::sign(lhs), SymEngine::floor(SymEngine::abs(lhs)))
in its place.
Any chance that truncate function will be implemented?
r1 = add(add(real_double(0.), x), y);
std::cout << *r1 << std::endl;
r1 = expand(add(add(real_double(0.), x), y));
std::cout << *r1 << std::endl;
r1 = expand(add(x, mul(real_double(4.), y)));
std::cout << *r1 << std::endl;
r1 = expand(add(x, mul(real_double(4.), add(y, z))));
std::cout << *r1 << std::endl;
r1 = expand(add(x, mul(integer(4), add(y, z))));
std::cout << *r1 << std::endl;
r1 = expand(mul(real_double(4.), add(y, z)));
std::cout << *r1 << std::endl;
r1 = expand(mul(integer(4), add(y, z)));
std::cout << *r1 << std::endl;
x + y
x + y
x + 4.0*y
0.0 + x + 4.0*y + 4.0*z
x + 4*y + 4*z
0.0 + 4.0*y + 4.0*z
4*y + 4*z
Add
and if the coefficient is 0.0
, remove it
0
for expand(4.0*(x + y - (x+y)))
is totally fine
@isuruf Hi Isuru, long time no see! Was wondering if the following behavior is expected. Thanks!! (master
, ed7479baf59a36636061acc35b676bcf9073a932
)
int main() {
RCP<const Basic> a = symbol("a"), b = symbol("b"), c = symbol("c");
map_basic_basic d {{mul(a,b), c}};
RCP<const Basic> r1 = mul(SymEngine::integer(2), mul(a, b)),
r2 = add(SymEngine::integer(1), r1);
std::cout << *r1 << " -> " << *r1->subs(d) << std::endl;
std::cout << *r2 << " -> " << *r2->subs(d) << std::endl;
return 0;
}
produces
2*a*b -> 2*a*b
1 + 2*a*b -> 1 + 2*c
2*a*b*c -> 2*a*b*c
1 + 2*a*b*c -> 1+2*a*b*c
The new as_ctypes API enables some really nice solver accuracy improvements for us downstream
What's the difference between this and the cython one?