-
Notifications
You must be signed in to change notification settings - Fork 306
Remove methods from core #738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes the following warning:
.../symengine/symengine/real_double.h:52:30: warning: inline function ‘virtual SymEngine::Evaluate& SymEngine::RealDouble::get_eval() const’ used but never defined [enabled by default]
inline virtual Evaluate& get_eval() const;
^
and a subsequent error:
../../libsymengine.a(visitor.cpp.o):(.data.rel.ro._ZTVN9SymEngine10RealDoubleE[_ZTVN9SymEngine10RealDoubleE]+0x98): undefined reference to `SymEngine::RealDouble::get_eval() const'
The only small issue is that I have removed the Number::diff() completely and reimplemented it in all the subclasses explicitly.
|
Now the only failure seems to be for optional MPFR and Arb. In fa17763 I implemented visitor like approach, for a new method So now the only difference between a visitor pattern and this is that the visitor pattern allows the user to implement new functionality without touching the core at all, for the price of one extra virtual function call. This PR gets rid of the extra virtual function call, but it requires to add a new method to And so I think we can use this approach to implement critical core functionality where we require maximum speed. We'll still allow the visitor approach, so that users can try out new things without modifying the core. We should also see if there is a way to unify the visitor class with the @isuruf and others, let me know what you think. |
This removes all declarations and implementations.
|
I finished the implementation and removed all old diff methods and instead use the new ones. Tests pass on Travis, the Appveyor failures are unrelated (we should however fix them to make sure this PR builds with MSVC). As to benchmarks, the only This is ready for a review. |
|
@certik, there's another way to implement this with little change. For each class we add methods like where and then it should work without other changes. This way we keep the functionality of Visitors. Visitors with no specific |
|
@isuruf indeed, we can now do that too. Do you have any objections against merging this PR? As to the Appveyor failure, I reported it here: http://help.appveyor.com/discussions/problems/3934-cannot-open-include-file-stdioh-no-such-file-or-directory (update: it's been fixed in Appveyor and I restarted the build) |
|
Looks good to me. +1 to merge after tests pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this macro, you can use std::enable_if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you use it in this particular case?
|
I pushed in two more patches that implement your idea for diff --git a/benchmarks/eval_double1.cpp b/benchmarks/eval_double1.cpp
index 4bcda19..92e4451 100644
--- a/benchmarks/eval_double1.cpp
+++ b/benchmarks/eval_double1.cpp
@@ -42,7 +42,7 @@ int main(int argc, char* argv[])
auto t1 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < 500; i++)
- r = eval_double(*e);
+ r = eval_double_single_dispatch2(*e);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout
<< std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1).count()without it I got: with it I got: So it seems it is a bit faster. I first tried to overload |
|
Hm, but the |
symengine/eval_double.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@certik, this is not going to work, as all the bvisit methods are going to be calling EvalRealDoubleVisitor's apply method
|
Indeed. I reseted to 6963b8c. I pushed the other patches into https://github.com/certik/symengine/tree/methods5 |
Now we are declaring the methods in just one place in basic-methods.inc.
|
I did push in 6201e78, since this should be part of this PR. This provides a solid foundation for our future PRs. |
|
Looks good to me too. |
|
Btw, here is how to port |
|
AppVeyor got stuck, I created #740 for that. |
|
See 98465c6, which builds on top of your str branch. |
|
+1 |
For now, I just removed
acceptanddiff. This will work for everything, likesubs, etc.This works similar to the visitor pattern, except that only a single virtual function call is used.
By using the @isuruf's trick with the
bvisitinline methods, this PR implements all derivatives asDiffImplementation::diffstatic methods.Performance should not be affected by this PR.