Sumith2016-08-20T21:01:22+00:00http://sumith1896.github.io/Sumithsumith1896@gmail.comSymPy at PyCon India 20152015-10-21T00:00:00+00:00http://sumith1896.github.io//SymPy-at-PyCon-India-2015<h3>The excitement</h3>
<p>People travelling from all over the country(and outside!) to Bangalore for a conference on a weekend, Yay! <br/>
We were really excited about the workshop and devsprint that the SymPy team was about to deliver. More so excited we were about the fact that we will finally be meeting one another.</p>
<h3>Day 0</h3>
<h4>DevSprint</h4>
<p>The first day of the conference kicked off with the devsprints. That morning the whole team met up, present there were Harsh, Sudhanshu, AMiT, Sartaj, Shivam and Sumith . Abinash couldn&#39;t make it but he was there in spirit :) <br/> We all got our awesome SymPy tees and stickers, thanks to AMiT. <br/>
Having got alloted mentoring space in the devsprint, basic introduction of SymPy was given by Sumith. Some interesting mentoring spaces were CPython by Kushal Das, Data Science by Bargava. The whole list is <a href="https://in.pycon.org/cfp/pycon-india-dev-sprint-2015/proposals/">here</a> <br/>
We got the participants started off with setting up the development workflow of SymPy and then they started working on the internals. We alloted bugs to many and directed them to the solution. Sadly, not many issues could alloted or closed due to the really poor internet connection at the conference hall but it was cool interacting with the enthusiasts. We also happened to meet Saurabh Jha, a contributor to SymPy who had worked on Linear Algebra and he helped us out with the devsprint.</p>
<h4>Workshop</h4>
<p>The workshops ran in two and a half hour slot. This was conducted by Harsh, Sudhanshu, AMiT and Sumith. <br/>
Sumith started off with introduction to SymPy. Then we spent some helping everyone setup their systems with SymPy and IPython notebooks, even though prior instructions were given, we had to do this so as to get everyone on level ground. <br/></p>
<p>Harsh took first half of the content and exercises <br/>
Sudhanshu took the second half, while AMiT and Sumith were helping out the participants with their queries. <br/></p>
<p><img src="/assets/pycon2015/workshop1.jpg" alt="PyCon"></p>
<p>We distributed t-shirts to all the participants at the end. Thanks to all those who participated, we had an awesome time.</p>
<p><img src="/assets/pycon2015/workshop2.jpg" alt="PyCon"></p>
<p>Day 0 ended with all of us wrapping off the devsprint. <br/>
After having dinner together, everybody headed back looking forward to the coming two days of the conference.</p>
<h3>Day 1</h3>
<p>Day 1 started off with a keynote by Dr Ajith Kumar B.P followed by multiple talks and lightning talks. <br/>
More interesting than the scheduled talks were the conversations that we had with people present in the conference. Exchanging views, discussing on a common point of interest was surely one of the best experience that I had.</p>
<h4>Lightning talk</h4>
<p>Shivam delivered a lightning talk titled <code>Python can be fast</code>. Here, he stressed on the fact that implementing correct data structures is important and Python is not always to be blamed. He gave relevant examples from his summers work at SymPy.</p>
<p><img src="/assets/pycon2015/lightningtalk.jpg" alt="PyCon"></p>
<p>By this point, we had reached considerable audience in the conference and lot of them were really interested in SymPy. We had a lot of younger participants who were enthusiastic about SymPy as it participates in GSoC, some of them also sent in patches.</p>
<blockquote class="twitter-tweet" lang="en"><p lang="en" dir="ltr">Hacking sympy with <a href="https://twitter.com/abraarsyed01">@abraarsyed01</a> <a href="https://twitter.com/ethcelon">@ethcelon</a></p>&mdash; Devyani Kota(divs) (@Devyani_kush) <a href="https://twitter.com/Devyani_kush/status/650565162584268800">October 4, 2015</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
<h3>Day 2</h3>
<p>Day 2 started off with a keynote by Nicholas H.Tollervey.</p>
<h4>Talk</h4>
<p>Sumith delivered a talk titled <code>SymEngine: The future fast core of computer algebra systems</code>. The content included SymPy, SymEngine and the interface. Some light was shed on Python wrappers to C++ code. Thanks to all the audience present there.</p>
<p><img src="/assets/pycon2015/talk.jpg" alt="PyCon"></p>
<p>As the day was closing in, Harsh and Shivam had to leave to catch their flights.</p>
<h4>Open Space</h4>
<p>After multiple people requesting to help them get started with SymPy, we decided to conduct an open space. <br/>
Open spaces are a way for people to come together to talk about topics, ideas or whatever they want. All people had to do is just show up :) Present there were Sudhanshu, Sartaj, AMiT and Sumith. Sartaj luckily came up with a <code>solveset</code> bug. We had a live show of how bug-fixing is done. Filing an issue, fixing the code, writing tests and sending in a PR was all demonstrated.</p>
<p><img src="/assets/pycon2015/openspace.jpg" alt="PyCon"></p>
<h3>Closing thoughts</h3>
<p>Conferences are the perfect place to discuss and share knowledge and ideas. The people present there were experts in their area of interests and conversations with them is a cool experience. Meeting the team was something that we were looking forward right from the start. </p>
<p><img src="/assets/pycon2015/team1.jpg" alt="PyCon"></p>
<p>Missing Sartaj and Abinash</p>
<p><img src="/assets/pycon2015/team2.jpg" alt="PyCon"></p>
<p>Discussing SymPy and the gossips in person is a different experience altogether. I&#39;ll make sure to attend all the conference that I possibly can from hereon. </p>
<p>Thanks for the reading <br/>
Be back for more <br/></p>
GSoC - Wrapping Up2015-08-21T00:00:00+00:00http://sumith1896.github.io//GSoC-Wrapping-Up<p>From not knowing anything considerable in programming and open source to reaching this level, has been a wonderful ride. Google Summer of Code has been full of ups and downs but none the less exhilarating. <br/></p>
<p>Didn&#39;t even know at the time of my <a href="https://github.com/sympy/symengine/commit/f5243c034953efa228c708e97668a932dc216e37">first patch</a> that I would be so closely associated to SymEngine and the team members just a few months down the line.</p>
<p>After a couple of bug fixes, my first major contribution came in as the <a href="https://github.com/sympy/symengine/blob/master/symengine/polynomial.cpp"><code>UnivariatePolynomial</code></a> class. The biggest challenge here was implementing multiplication using Kronecker&#39;s trick. This was my first experience of implementing an algorithm from a <a href="http://www.cs.berkeley.edu/%7Efateman/papers/polysbyGMP.pdf">paper</a>. The <code>UnivariatePolynomial</code> class shaped up really well, there are minor improvements that can be made and some optimizations that could be done. But standalone, it is a fully functional class.</p>
<p>Once this was done, my next aim was to optimize multiplication to reach <code>Piranha</code>&#39;s speed. This was a very enriching period and the discussions with the team members and <a href="https://github.com/bluescarni">Francesco</a> was a great learning experience. En route, I also got a chance to explore <code>Piranha</code> under the hood and trouble Francesco for reasoning why certain things were the way they. End of this, we were able to hit <code>Piranha</code>&#39;s speed. I remember I was the happiest I had been in days.</p>
<p>Once we hit the lower level speed, we decided to hard-depend on <code>Piranha</code> for <code>Polynomial</code>. This meant adding <code>Piranha</code> as SymEngine dependence. Here I had to learnt how to write and wrote <code>CMake</code> files as well as setting up Piranha testing in <code>Travis</code> meant writing <code>shell</code> and <code>CI</code> scripts. We faced a problem here, resolution to which meant implementing <code>Catch</code> as a testing framework for <code>SymEngine</code>. <code>Catch</code> is an awesome library and community is very pleasant. Implementing this was a fun work too.
Also the high level value class <code>Expression</code> was implemented in <code>SymEngine</code>, mostly taken from Francesco&#39;s work.</p>
<p>I then started writing the <code>Polynomial</code> class, most of the work is done here(<a href="https://github.com/sympy/symengine/pull/597">597</a>). But the design is not very well thought of. I say this because once ready this can only support integer(ZZ) domain. But we will also need rational(QQ) and expression(EX). The code will be of much use but we have been discussing a much cleaner implementation with <code>Ring</code> class. Most of the progress and the new design decisions are being documented <a href="https://github.com/sympy/symengine/wiki/En-route-to-Polynomial">here</a>.</p>
<p>Second half has been really rough, with the university running. Ondrej has been really patient with me, I thank him for that. The bond that I made with him through mails, technical and non technical, has really grown strong. He has allowed me to continue the work the <code>Polynomial</code> and implement more details and algorithms in future. I am looking forward to that as long term association is an amazing thing and I am proud to be responsible for the <strong><code>Polynomial module in SymEngine</code></strong>.</p>
<p>I am indebted to my mentor <a href="https://github.com/certik">Ondrej Certik</a> and all the <a href="https://gitter.im/sympy/symengine">SymEngine</a> and <a href="https://gitter.im/sympy/sympy">SymPy</a> developers who were ever ready to help and answer my silliest of questions. It’s an amazing community and they are really very helpful and always appreciated even the smallest of my contributions. The best part of SymEngine is you know contributors one to one and it is like a huge family of learners. I am looking forward to meeting the team (atleast SymPy India in near future).</p>
<p>Google Summer of Code has been one exhilarating journey. I don&#39;t know if I was a good programmer then or a good programmer now but I can say that I am a better programmer now.</p>
<p><strong>This is just the beginning of the ride, GSoC a stepping stone.</strong></p>
<p>There will be blog posts coming here, so stay tuned. Till then, <br/>
<strong>Bye</strong></p>
GSoC Progress - Week 10 and 112015-08-16T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-10-&-11<p>Hello all. Here are the most recent developments in the Polynomial wrappers.</p>
<h3>Report</h3>
<ul>
<li><p>The Polynomial wrappers was using <code>piranha::hash_set</code> as the <code>Polynomial</code> wrappers, hence when there was no <code>Piranha</code> as a dependence, the <code>Polynomial</code> wouldn&#39;t compile. The fix to this was to use <code>std::unordered_set</code> with <code>-DWITH_PIRANHA=no</code> so that there would be atleast a slow version available.</p></li>
<li><p>Another issue was Travis testing of <code>Polynomial</code>. Since we depend on <code>Piranha</code>, we had to setup Travis testing with <code>Piranha</code> included and <code>Polynomial</code> tests run. This was done in the merged PR <a href="https://github.com/sympy/symengine/pull/585">585</a>.</p></li>
<li><p>Before we get the <code>Polynomial</code> merged we have to add <code>mul_poly</code>, improve printing, and test exhaustively. The <code>mul_poly</code> is ready <a href="https://github.com/shivamvats/symengine/pull/4">here</a>, will be merged once more tests are prepared.</p></li>
</ul>
<p>For <code>mul_poly</code>, previously we never checked the variables corresponding to the <code>hash_set</code>s, which implies you could only multiply a <code>n</code> variable polynomial with another <code>n</code> variable polynomial with the variable symbols same in both. When the variables of two hash_sets are different, a work around would be needed. This would result in slow down if done directly.</p>
<p>As suggested by <a href="https://github.com/certik">Ondřej</a>, <code>mul_poly</code> now calls two functions <code>_normalize_mul</code> and <code>_mul_hashest</code>. Here <code>_noramlize_mul</code> sees to it that the <code>hash_set</code>s satisfy the afore mentioned criteria and then <code>_mul_hashset</code> operates <br/>
For example, say <code>mul_poly</code> is called,
then <code>_normalize_mul</code> converts <code>{1, 2, 3}</code> of <code>x, y, z</code> and <code>{4, 5, 6}</code> of <code>p, q, r</code> to <code>{1, 2, 3, 0, 0, 0}</code> and <code>{0, 0, 0, 4, 5, 6}</code>
and <code>_mul_hashset</code> multiplies the two <code>hash_set</code>. The speed of benchmarks determined by <code>_mul_hashset</code>.</p>
<ul>
<li><p>The printing needs improvement. As of now the polynomial <code>2*x + 2*y</code> gets printed as <code>2*y**1*x**0 + 2*y**0*x**1</code>.</p></li>
<li><p>Not all that was planned could be completed this summers, mostly because of my hectic schedule after the vacations ended and institure began. I am planning to work after the program ends too, when the workload eases. As the final deadline week of GSoC is coming up, I need to ensure at least the PRs on hold gets merged.I am planning to continue after the period ends so as </p></li>
</ul>
<p>That&#39;s all I have <br/>
<strong>See ya</strong></p>
GSoC Progress - Week 92015-07-24T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-9<p>Hello all. Last week has been rough, here&#39;s what I could do.</p>
<h3>Report</h3>
<p>The printing now works, hence I could test them. Due to that we could even test both the constructors, one from <code>hash_set</code> and other from <code>Basic</code>.</p>
<p>The Polynomial wrappers PR, we need to get in quick, our highest priority.</p>
<p>We need to make the methods more robust, we plan to get it in this weekend. <br/>
Once this is in, <a href="https://github.com/shivamvats">Shivam</a> can start writing function expansions.</p>
<p>I have also couple of other tasks:</p>
<ul>
<li>Use <code>std::unordered_set</code> so that we can have something even when there is no Piranha as dependency. <br/></li>
<li>Replace <code>mpz_class</code> with <code>piranha::integer</code> throughout SymEngine and checkout benchmarks.</li>
</ul>
<p>I intend to get Polynomial in this weekend because I get free on weekends :) <br/>
As there are only 3-4 weeks remaining, I need to buck up.</p>
<p>That&#39;s all I have <br/>
<strong>Bidāẏa</strong></p>
GSoC Progress - Week 82015-07-17T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-8<p>Hello. Short time since my last post. Here&#39;s my report since then.</p>
<h3>Progress</h3>
<p>I have continued my work on the Polynomial wrappers.</p>
<p>Constructors from <code>hash_set</code> and <code>Basic</code> have been developed and pushed up. Printing has also been pushed. I&#39;m currently writing tests for both, they&#39;ll be ready soon.</p>
<p>When <code>hash_set_eq()</code> and <code>hash_set_compare()</code> were developed, we realised that there were many functions in <code>*_eq()</code> and <code>*_compare()</code> form with repeated logic, the idea was to templatize them which <a href="https://github.com/shivamvats">Shivam</a> did in his PR <a href="https://github.com/sympy/symengine/pull/533">#533</a>.</p>
<p>Solution to worry of slow compilation was chalked which I wish to try in the coming week, using <code>std::unique_ptr</code> to a <code>hash_set</code>, instead of a straight <code>hash_set</code>. Hence not necessary to know the full definition of <code>hash_set</code> in the header. I&#39;ve been reading relevant material, known as <code>PIMPL</code> idiom.</p>
<h3>Report</h3>
<p><strong>WIP</strong> <br/>
* <a href="https://github.com/sympy/symengine/pull/511">#511</a> - Polynomial Wrapper <br/></p>
<h3>Targets for Week 9</h3>
<p>I wish to develop the <code>Polynomial</code> wrappers further in the following order. <br/></p>
<ul>
<li>Constructors and basic methods, <code>add</code>, <code>mul</code>, etc, working with proper tests. <br/></li>
<li>Solve the problem of slow compilation times. <br/></li>
<li>As mentioned previously, use standard library alternates to Piranha constructs so that we can have something even when there is no Piranha as dependency. <br/></li>
</ul>
<p>After the institute began, the times have been rough. Hoping everything falls in place. <br/></p>
<p>Oh by the way, <a href="http://www.sympy.org/en/index.html">SymPy</a> will be present (and represented heavily) at <a href="https://in.pycon.org/2015/">PyCon India 2015</a>. We sent in the content and final proposal for review last week. Have a look at the website for our proposal <a href="http://iamit.in/sympy-pycon/">here</a>.</p>
<p>That&#39;s all this week. <br/>
<strong>sayōnara</strong></p>
GSoC Progress - Week 72015-07-13T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-7<p>Hello. Sorry for the really late post. As I was moving from home to Mumbai back and also part of the grading team of International Physics Olympiad(IPhO), I could not contribute as much as I had thought I could. Here is what I have for this week.</p>
<h3>Progress</h3>
<p>The <code>Expression</code> class was built upon the initial works of Francesco. I made a SymEngine patch with his as an initial commit. We now have a top-level value class.</p>
<p>The slowdowns finally got tackled. It was Piranha that needed amendment. The slowdown, as discussed previously, was due to the class <code>thread_pool</code>. This was resolved was templatizing <code>thread_pool</code> i.e. replace <code>class thread_pool: private detail::thread_pool_base&lt;&gt;</code> with <code>template &lt;typename = void&gt; class thread_pool_: private detail::thread_pool_base&lt;&gt;</code>. This basically saw to it that inclusion of individual headers. Including single <code>piranha.hpp</code> still had this problem. The problem was <code>piranha.hpp</code> includes <code>settings.hpp</code>, which in turn defines a non-template function called <code>set_n_threads()</code> which internally invokes the thread pool. This was resolved by a similar fix, the <code>setting</code> class to <code>&lt;typename = void&gt; class settings_</code>.</p>
<p>Many things were reported until now, hence <a href="https://github.com/certik">Ondřej</a> suggested a documentation of all the decisions taken. The wiki page, <a href="https://github.com/sympy/symengine/wiki/En-route-to-Polynomial">En route to Polynomial</a> was hence made.</p>
<h3>Report</h3>
<p><strong>WIP</strong> <br/>
* <a href="https://github.com/sympy/symengine/pull/511">#511</a> - Polynomial Wrapper <br/></p>
<p><strong>Merged</strong> <br/>
* <a href="https://github.com/sympy/symengine/pull/512">#512</a> - Add Francesco to AUTHORS <br/>
* <a href="https://github.com/sympy/symengine/pull/500">#500</a> - Expression wrapper. <br/></p>
<p><strong>Documentation</strong> <br/>
<a href="https://github.com/sympy/symengine/wiki/En-route-to-Polynomial">En route to Polynomial</a></p>
<h3>Targets for Week 8</h3>
<p>Get the <code>Polynomial</code> wrapper merged.</p>
<p>Points to be noted: <br/>
* Use standard library alternates to Piranha constructs so that we can have something even when there is no Piranha as dependency. <br/>
* Basic class in, so that <a href="https://github.com/shivamvats">Shivam</a> can start some work in SymEngine. <br/></p>
<p>I am thankful to <a href="https://github.com/certik">Ondřej</a> and the <code>SymEngine</code> team for bearing with my delays. I hope I can compensate in the coming week. </p>
<p>That&#39;s all this week. <br/>
<strong>Adéu</strong></p>
GSoC Progress - Week 62015-07-03T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-6<p>Hello, received a mail few minutes into typing this, passed the midterm review successfully :) <br/>
Just left me wondering how do these guys process so many evaluations so quickly. I do have to confirm with <a href="https://github.com/certik">Ondřej</a> about this. <br/>
Anyways, the project goes on and here is my this week&#39;s summary. <br/></p>
<h3>Progress</h3>
<p><code>SymEngine</code> successfully moved to using <code>Catch</code> as a testing framework. </p>
<p>The travis builds for clang were breaking, this let me to play around with travis and clang builds to fix this issue. The linux clang build used to break because we used to mix-up and link libraries like <code>GMP</code> compiled with different standard libraries. <br/>
Thanks to <a href="https://github.com/isuruf">Isuru</a> for lending a helping hand and fixing it in his PR.</p>
<p>Next task to make <code>SYMENGINE_ASSERT</code> not use standard <code>assert()</code>, hence I wrote my custom assert which simulates the internal <code>assert</code>. <br/>
Now we could add the <code>DNDEBUG</code> as a release flag when <code>Piranha</code> is a dependence, this was also done.</p>
<p>Started work on <code>Expression</code> wrapper, PR that starts off from Francesco&#39;s work sent in.</p>
<p>Investigated the slow down in benchmarks that I have been reporting in the last couple of posts. Using <code>git commit</code>(amazing tool, good to see binary search in action!), the first bad <a href="https://github.com/Sumith1896/csympy/commit/35f384a484315efbb900ec4ec0b0eb97e791c193">commit</a> was tracked. We realized that the inclusion of <code>piranha.hpp</code> header caused the slowdown and was resolved by using <code>mp_integer.hpp</code>, just the requirement header. <br/>
With immense help of <a href="https://github.com/bluescarni">Franceso</a>, the problem was cornered to this: <br/>
* Inclusion of <code>thread_pool</code> leads to the slowdown, a global variable that it declares to be specific. <br/>
* In general a multi-threaded application may result in some compiler optimizations going off, hence slowdown. <br/>
* Since this benchmark is memory allocation intensive, another speculation is that compiler allocates memory differently. <br/></p>
<p>This SO <a href="http://stackoverflow.com/questions/31212943/performance-cost-of-threading-constructs-missed-optimisations-and-memory-alloca">question</a> asked by <a href="https://github.com/bluescarni">@bluescarni</a> should lead to very interesting developments. </p>
<p>We have to investigate this problem and get it sorted. Not only because we depend on <code>Piranha</code>, we might also have multi-threading in <code>SymEngine</code> later too.</p>
<h3>Report</h3>
<p>No benchmarking was done this week. <br/>
Here is my PR reports. <br/></p>
<p><strong>WIP</strong> <br/>
* <a href="https://github.com/sympy/symengine/pull/500">#500</a> - Expression Wrapper <br/></p>
<p><strong>Merged</strong> <br/>
* <a href="https://github.com/sympy/symengine/pull/493">#493</a> - The PR with <code>Catch</code> got merged. <br/>
* <a href="https://github.com/sympy/symengine/pull/498">#498</a> - Made <code>SYMENGINE_ASSERT</code> use custom assert instead of <code>assert()</code> and <code>DNDEBUG</code> as a release flag with <code>PIRANHA</code>. <br/>
* <a href="https://github.com/sympy/symengine/pull/502">#502</a> - Make <code>poly_mul</code> used <code>mpz_addmul</code> (FMA), nice speedup of <code>expand2b</code>.
* <a href="https://github.com/sympy/symengine/pull/496">#496</a> - En route to fixing <code>SYMENGINE_ASSERT</code> led to a minor fix in one of the assert statements. <br/>
* <a href="https://github.com/sympy/symengine/pull/491">#491</a> - Minor fix in compiler choice documentation.</p>
<h3>Targets for Week 7</h3>
<ul>
<li>Get the <code>Expression</code> class merged. <br/></li>
<li>Investigate and fix the slow-downs. <br/></li>
</ul>
<p>The rest of tasks can be finalized in later discussion with <a href="https://github.com/certik">Ondřej</a>.</p>
<p>That&#39;s all this week. <br/>
<strong>Ciao</strong></p>
GSoC Progress - Week 52015-06-26T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-5<p>Hello, this post contains the fourth report of my GSoC progress. We hit <code>Piranha</code>&#39;s speed,
the highlight of this week. </p>
<h3>Progress</h3>
<p>We were able to reach <code>Piranha</code>&#39;s speed. At an average <code>14-ish ms</code> to the benchmark, we are happy enough (still can be improved) to start wrapping this low-level implementation to a <code>Polynomial</code> class. Last week I had reported speed <code>23ms</code> and this week we are better. <br/></p>
<p>We had missed out a compiler flag, <code>DNDEBUG</code> to indicate <code>Release</code> mode of <code>Piranha</code> leading to slow-down, <a href="https://github.com/sympy/symengine/issues/482">#482</a>. <br/>
Adding this compiler flag means we should not be using <code>assert</code> statement, which <code>SymEngine</code> does in <code>SYMENGINE_ASSERT</code> and test files too. These had to be sorted out if <code>Piranha</code> were to be a hard dependency of <code>SymEngine</code>&#39;s polynomial module. <br/></p>
<p>Hence, the issue of moving the tests suite from <code>assert</code>s to a well-developed test framework came up again, <a href="https://github.com/sympy/symengine/issues/282">#282</a>. We explored a couple, but <code>Catch</code> still seemed to be the best option. <br/>
<code>Catch</code> was implemented, which is a benefit to <code>SymEngine</code> in the long run too. <br/>
As for the <code>SYMENGINE_ASSERT</code>, we decided to change our macro to raise an exception or just abort the program. <br/>
<a href="https://github.com/philsquared/Catch">Catch</a> is a very good tool. We thank <a href="https://github.com/philsquared">Phil Nash</a> and all the contributors for making it.</p>
<p>Next up, wrapping into <code>Polynomial</code>. <br/></p>
<ul>
<li><p>We need some functionality to convert a <code>SymEngine</code> expression(<code>Basic</code>) into one of <code>hashset</code> representations directly. Now I convert <code>basic</code> to <code>poly</code> and then to <code>hashset</code> as just getting the speed right was the issue. <br/></p></li>
<li><p>Domains of coefficients need to be thought of. <code>SymPy</code> and <code>Sage</code> will be need to looked into and their APIs need to be studied. We need <code>ZZ</code>, <code>QQ</code> and <code>EX</code>, the work for <code>EX</code> has been done by <a href="https://github.com/bluescarni">Francesco Biscani</a>, this will be patched for the latest master and commited in his name.
There could also be an automatic mode, which figures out the fastest representation for the given expression, at the price of a little slower conversion, as it needs to traverse the expression to figure out what representation fits. <br/></p></li>
<li><p><code>tuple</code> to <code>packed</code> conversion when exponents don&#39;t fit. Also <code>encode</code> supports signed ints which is a boon to us, as we don&#39;t have to worry about negative exponents. For <code>rational</code> exponents we use tuple. <br/></p></li>
</ul>
<p>I still haven&#39;t figured out the reason for slow down of <code>expand2</code> and <code>expand2b</code> in my <code>packint</code> branch. I have been suggested to use <code>git bisect</code>. Will do next week.</p>
<h3>Report</h3>
<p><code>expand2d</code> results:</p>
<p>Result of 10 execution: <br/>
<code>14ms</code> <br/>
<code>14ms</code><br/>
<code>14ms</code> <br/>
<code>15ms</code> <br/>
<code>14ms</code> <br/>
<code>15ms</code> <br/>
<code>14ms</code> <br/>
<code>14ms</code> <br/>
<code>15ms</code> <br/>
<code>14ms</code> <br/></p>
<p>Maximum: 15ms <br/>
Minimum: 14ms <br/>
Average: 14.3ms <br/></p>
<p>Here, the <code>evaluate_sparsity()</code> gave the following result for the <code>hash_set</code> <br/></p>
<p><code>0,11488</code> <br/>
<code>1,3605</code> <br/>
<code>2,1206</code> <br/>
<code>3,85</code> <br/></p>
<p><code>Piranha</code> has the following results <br/></p>
<p><code>Average: 13.421ms</code> <br/>
<code>Maximum: 13.875ms</code> <br/>
<code>Minimum: 12.964ms</code> <br/></p>
<p>A more detailed report of benchmarks and comparisons can be found <a href="https://github.com/sympy/sympy/wiki/Benchmark-results-expand2b,-SymEngine">here</a></p>
<p>A minor PR where MPFR was added as a Piranha dependency, <a href="https://github.com/sympy/symengine/pull/472">472</a> was merged. <br/></p>
<p>Another PR in which the tests where moved to <code>Catch</code> is good to play with and merge, minor build nits remaining, <a href="https://github.com/sympy/symengine/pull/484">484</a>. <br/></p>
<h3>Targets for Week 5</h3>
<ul>
<li>Figure out the reason for <a href="https://github.com/sympy/sympy/wiki/Benchmark-results-expand2b,-SymEngine#why-is-there-a-slowdown-in-packint-branch-for-expand-and-expand2b">slow down</a> in benchmarks, fix that. <br/></li>
<li>Change the <code>SYMENGINE_ASSERT</code> <a href="https://github.com/sympy/symengine/blob/bbe3c9baf653d18d37e3bfcd424e0781786098c1/symengine/symengine_assert.h#L7">macro</a> to raise an <a href="https://github.com/sympy/symengine/blob/bbe3c9baf653d18d37e3bfcd424e0781786098c1/symengine/symengine_assert.h#L13">exception</a>. <br/></li>
<li>Add the <code>DNDEBUG</code> flag for with <code>Piranha</code> builds, as now <code>SymEngine</code> doesn&#39;t use <code>assert</code>, close issue <a href="https://github.com/sympy/symengine/issues/482">#482</a>.</li>
<li>Port <a href="https://github.com/bluescarni"><code>@bluescarni</code></a>&#39;s <a href="https://github.com/sympy/symengine/compare/master...bluescarni:expression">work</a> of <code>EX</code> to SymEngine. <br/></li>
<li>Wrap the lower-level into <code>Polynomial</code> for signed integer exponents in <code>ZZ</code> domain with functionality atleast that of <code>UnivariatePolynomial</code>. <br/></li>
</ul>
<p>That&#39;s all this week. <br/>
<strong>Sbohem</strong></p>
GSoC Progress - Week 3 and 42015-06-20T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-3-and-4<p>Hello, this post contains the third report of my GSoC progress. At one point, I had changed the deadline from Sundays to Fridays, but I seem to be running a week late on the post names. That has been corrected now</p>
<h3>Progress</h3>
<p>We decided to replace <code>mpz_class</code> with <code>piranha::integer</code> for coefficients and <code>std::unordered_map</code> with <code>piranha::hash_set</code> for the container. We got the lower-level working with this data-structure in the last week. <br/>
We decided to depend on <code>Piranha</code> for the <code>Polynomial</code> else our module won&#39;t be upto the speed we expect it to. <br/>
In future, we can write our hashtable and Integer as and when needed. <br/></p>
<h3>Report</h3>
<p>The benchmarks results are: <br/></p>
<p><code>expand2b</code> has: <br/></p>
<p><code>Average: 108.2ms</code> <br/>
<code>Maximum: 114ms</code> <br/>
<code>Minimum: 107ms</code> <br/></p>
<p>while the latest <code>expand2d</code> has: <br/></p>
<p><code>Average: 23ms</code> <br/>
<code>Maximum: 23ms</code> <br/>
<code>Minimum: 23ms</code> <br/></p>
<p>which is a nice 4-5x speed-up. <br/>
The code for this(experimental) can be found in <a href="https://github.com/sympy/symengine/pull/470">470</a>. <br/>
A more detailed report can be found <a href="https://github.com/sympy/sympy/wiki/Benchmark-results-expand2b,-SymEngine">here</a>. <br/></p>
<p>I also sent in a minor PR with some clean-ups that I felt neccessary in <a href="https://github.com/sympy/symengine/pull/472">472</a>.</p>
<h3>Targets for Week 5</h3>
<ul>
<li>Wrap the the lower level into a <code>Polynomial</code> class.</li>
<li>Have the functionality of atleast the <code>UnivariatePolynomial</code> class.</li>
<li>Explore what kind of coefficients can be passed, since we have <code>piranha::integer</code> we need to think of having <code>rational</code> and <code>symbolic</code> coefficients now itself.</li>
<li>Think of various areas where <code>Polynomial</code> class needs to integrate in SymEngine for example <code>expand()</code></li>
</ul>
<p>That&#39;s all this week. <br/>
<strong>Vaarwel</strong></p>
GSoC Progress - Week 22015-06-12T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-2<p>Hello, this post contains the second report of my GSoC progress. At one point, I had changed the deadline from Sundays to Fridays, but I seem to be running a week late on the post names. Will be corrected next week.</p>
<h3>Progress</h3>
<p>We decided that instead of coding up the <code>Polynomial</code> upfront, we try to speed up the expand2b benchmark i.e. try to nail speed at a lower level, then think of the design decisions and wrap it up into <code>Polynomial</code> class. <br/>
The plan was this: <br/>
* Add support for <code>Piranha</code> in <code>SymEngine</code> CMake <br/>
* Implement packing of exponents and a check function to ensure it fits, use this to fasten expand2b <br/>
* Use Piranha&#39;s integer and benchmark expand2b again <br/></p>
<p>The faster hashtable was kept for later.</p>
<h3>Report</h3>
<p><a href="https://github.com/sympy/symengine/pull/464">PR 464</a> was merged. <br/>
Implements support for <code>Piranha</code> in CMake along with it&#39;s dependencies <code>Boost</code> and <code>PTHREAD</code>. <br/>
The above two dependencies come as separate CMake option as well. We feel that the <code>Boost</code> support can be improved, that can be done at a later stage.</p>
<p><a href="https://github.com/sympy/symengine/pull/470">PR 470</a> Speeding up the benchmark. <br/>
* The pack and check function were implemented <br/>
* Used <code>std::valarray</code> instead <code>std::vector</code>(inspired by <a href="https://github.com/sympy/symengine/issues/111">issue 111</a>) but the benchmark slowed down, hence change was not adopted <br/>
* Implemented functions <code>poly2packed()</code> and <code>packed2poly()</code>, for converting between the two representations <br/>
* Implemented function <code>poly_mul2()</code> for multiplying the packed polynomials <br/>
* Re-wrote <code>expand2b</code> to use packed, now <code>expand2c</code> <br/></p>
<p>Very nice speedup was obtained from using the packed structure, a more detailed report can be found <a href="https://github.com/sympy/sympy/wiki/Benchmark-results-expand2b,-SymEngine">here</a>. <br/>
But we are still far from <code>Piranha</code> and we have lots to do :)</p>
<p>Most of the week&#39;s time went to learning to link libraries and writing cmake files for my own projects so that I could figure what was happening in <a href="https://github.com/sympy/symengine/pull/464">PR 464</a>. Now I feel it was very easy a task and shouldn&#39;t have consumed the time it did.</p>
<h3>Targets for Week 3</h3>
<p>My aim is to get all the code and optimization, possible at this level, done by next week, so that we can start wrapping in the coming weeks. <br/>
* Use <code>piranha::integer</code> for coefficients, benchmark <br/>
* Implement switching between packed structure and tuple depending on whether exponents fit or not <br/></p>
<p>If time permits, I want to implement a system to use <code>int</code> for small cofficients and switch to <code>mpz_class</code> when large.<br/>
We have lots to do to hit the speed that we expect.<br/></p>
<p>That&#39;s all folks.<br/>
<strong>Au Revoir</strong></p>
GSoC Progress - Week 12015-06-05T00:00:00+00:00http://sumith1896.github.io//GSoC-Progress-Week-1<p>Hi again, this post contains the first report of my GSoC progress, even though it&#39;s week 2. </p>
<h3>Progress</h3>
<p>I have completed the <code>UnivariatePolynomial</code> implementation in <a href="https://github.com/sympy/symengine/pull/454">PR 454</a>, the PR is reviewed and merged. This <code>SymEngine</code> class can handle univariate polynomials and can handle all the basic polynomial manipulation.</p>
<p>The current functionality of <code>UnivariatePolynomial</code> are:<br/>
* two constructors of <code>UnivariatePolynomial</code> class, one using a <code>dict</code> of degree to coefficient and other is using a dense vector of coefficients. Note that this implementation is sparse. <br/>
* printing, same output pattern as that of SymPy<br/>
* <code>from_dict</code> which returns the appropriate <code>Basic</code> type on passing the <code>dict</code><br/>
* <code>dict_add_term</code> to add a new term to the <code>dict</code><br/>
* <code>max_coef()</code>, <code>diff()</code>, <code>eval()</code> as the name suggests<br/>
* some bool check funtions to check specific cases like <code>is_zero()</code>, <code>is_one()</code>, etc.<br/>
* also the <code>add</code>, <code>sub</code>, <code>neg</code> and <code>mul</code> functions. <br/></p>
<p>What I learnt here was having a testing environment setup first speeds up the process of implementation and things go in the right direction.<br/></p>
<h3>Report</h3>
<p>The <code>UnivariatePolynomial</code> uses <code>std::map</code>, I plan to switch to <code>std::unordered_map</code> or other specialized data structures before benchmarking the class and comparing speeds so that we get a decent speed.<br/>
The, to be implemented, multivariate class will be called <code>Polynomial</code>. Note that two classes are high level, because they can take part in SymPy expressions.</p>
<p>The plan is to implement lower level classes with various data structures, as well as using Piranha. These lower level classes do not use RCP at all, thus they could be faster for some applications. The user could then call specialized classes if needed for a given application (if we implement any).</p>
<h3>Targets for Week 2 and Week 3</h3>
<p>First aim is to use the already implemented polynomials in <a href="https://github.com/sympy/symengine/blob/master/src/rings.cpp"><code>rings</code></a> in SymEngine, look at the <a href="https://github.com/sympy/symengine/blob/master/benchmarks/expand2b.cpp">expand2b</a> benchmark and try to speed it up by: <br/>
* Making use of Piranha int <br/>
* Using Kronecker packing for exponents </p>
<p>If we get satisfactory speed, we wrap it in <code>Polynomial</code> class. This can further be optimized using our very own class Integer, where in it we switch between int and mpzclass automatically (we should use it everywhere in SymEngine instead of mpzclass) and hashmap in future.</p>
<p><strong>Tasks</strong> <br/>
* have an option of <code>Piranha</code> in cmake <br/>
* code for packing exponents into machine int64 <br/>
* try to use Piranha&#39;s integer to see how it performs <br/>
If time permits <br/>
* Implement faster hashmap this weekend with <a href="https://github.com/shivamvats">Shivam</a></p>
<p>That&#39;s all for now. Catch you next week.<br/>
<strong>Adiós</strong></p>
Gearing up for GSoC2015-05-25T00:00:00+00:00http://sumith1896.github.io//Gearing-up-for-GSoC<p>Greetings! The community bonding is officially closed now. It&#39;s time for the coding period. I had promised myself a post every sunday from the 24th of May 2015 but seems like the first post is a bit late. </p>
<h3>Community bonding</h3>
<p>I had discussions with <a href="https://github.com/certik">Ondřej</a> and <a href="https://github.com/shivamvats">Shivam</a> about the big tasks in hand and how to go about handling the work. In the first discussion, we also assigned ourselves the first task that needs to be completed.<br/>
I have to:<br/>
* Clean up the necessary in the <a href="https://github.com/sympy/symengine/pull/406">PR</a> Shivam had sent during his proposal period.<br/>
* Implement <code>sub_poly()</code> and <code>mul_poly()</code> with Kronecker substitution in a clean fashion.<br/>
Shivam agreed to finish <code>ring_series</code> in <a href="https://github.com/sympy/sympy">SymPy</a> which he has already started working on.<br/>
Also together we decided to work on a faster hashtable implementation.<br/>
I also discussed with <a href="https://github.com/sushant-hiray">Sushant</a> about the structure of the current <a href="https://github.com/sympy/symengine">SymEngine</a> and cleared my doubts there.<br/></p>
<p>As a part of community bonding, I looked to some tools that I&#39;ll be using. Certain C++11 constructs, visitor pattern, etc. Even though I am not thorough with it, I think learning it as I progress with the work is the best thing to do.</p>
<p>Regarding the work I undertook in this period, is minimal, but here they are:<br/>
<strong>Issues</strong><br/>
<a href="https://github.com/sympy/symengine/issues/443">#443</a>: Documentation of SymEngine.<br/>
<strong>Pull requests</strong><br/>
As I read through the code I felt some clean ups necesarry which were done in <br/>
<a href="https://github.com/sympy/symengine/pull/444">#444</a> and <a href="https://github.com/sympy/symengine/pull/438">#438</a>: Pending<br/>
<a href="https://github.com/sympy/symengine/pull/451">#451</a>, <a href="https://github.com/sympy/symengine/pull/442">#442</a>, <a href="https://github.com/sympy/symengine/pull/441">#441</a> and <a href="https://github.com/sympy/symengine/pull/440">#440</a>: Merged<br/></p>
<p>In my proposal, I had promised <a href="https://github.com/bluescarni/piranha">Piranha</a> audit but it didn&#39;t happen in such a short period due to complex code. Best way to go forward was to start work for <code>Polynomial</code>.<br/>
The work regarding <code>Polynomial</code> class has already begun <a href="https://github.com/sympy/symengine/pull/454">here</a>. I thank the whole <a href="https://github.com/sympy/symengine">SymEngine</a> community for actively participating there and giving their inputs.<br/></p>
<h3>Targets for Week 1</h3>
<p>Complete the <code>Polynomial</code> class, need to implement:<br/>
* basic functions <code>__hash__</code>, <code>__eq__</code>, <code>compare</code>, <code>from_dict</code> like other SymEngine classes.<br/>
* Implement printer and tests for that.<br/>
* Implement <code>add_poly()</code>, <code>neg_poly()</code>, <code>sub_poly()</code>, <code>mul_poly()</code>, <code>eval()</code> and respective tests.<br/>
If possible, time permits<br/>
* Start working on the hashtable along with <a href="https://github.com/shivamvats">Shivam</a>.<br/></p>
<p>I am really excited as the coding period has officially started. The whole <a href="https://github.com/sympy/symengine">SymEngine</a> community has been active on <a href="https://gitter.im/sympy/symengine">Gitter</a> as well as <a href="https://github.com/sympy/symengine/pull/454">PR</a> discussion, looking forward to awesome learning experience with them.</p>
<p>That&#39;s all for now. Catch you next week.<br/>
<strong>Freilos</strong>(German)</p>
Google Summer Of Code with SymPy2015-05-10T00:00:00+00:00http://sumith1896.github.io//Google-Summer-Of-Code-with-SymPy<p><img src="/assets/gsoc/GSOC2015.png" alt="GSoC 2015"></p>
<p>Hi there! The Google Summer of Code results are out and I have been selected. As mentioned in a previous post, my project of <code>Implementing polynomial module in CSymPy</code> has been selected and I get to work with <a href="http://www.sympy.org/">SymPy</a> under <a href="https://www.python.org/psf/">Python Software Foundation.</a>.</p>
<h3>The excitement</h3>
<p>I really thank the community for accepting a freshman do a project. The community over at SymPy is so helpful and the working environment real fun that has motivated me to take up this project.<br/>
My mentors are <a href="https://github.com/certik">Ondřej Čertík</a> himself and <a href="https://github.com/sushant-hiray">Sushant Hiray</a>, who is a previous GSoC-cer at SymEngine(then CSymPy).<br/>
I&#39;d also like to congratulate <a href="https://github.com/shivamvats">Shivam</a>, <a href="https://github.com/isuruf">Isuru</a>, <a href="https://github.com/abinashmeher999">Abinash</a> for getting projects under SymEngine and all others who have been selected under SymPy and Python Software Foundations in general.<br/>
I am excited for the summer to follow and the great learning experience ahead.</p>
<h3>SymPy and SymEngine</h3>
<p><img style="float: right" src="/assets/gsoc/sympy.png"></p>
<blockquote>
<p>SymPy is a Python library for symbolic mathematics. It aims to become a full-featured <strong><a href="http://en.wikipedia.org/wiki/Computer_algebra_system">Computer Algebra System</a></strong> (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible.</p>
<p><a href="https://github.com/sympy/symengine">SymEngine</a> is a fast symbolic manipulation library, written in C++.
Plans to be the fast swappable SymPy core and also a CAS on it&#39;s own. We are currently writing Ruby and Julia wrappers for it too.</p>
</blockquote>
<h3>The Project</h3>
<p>SymEngine currently lacks a polynomial module which is very essential in achieving SymEngine&#39;s goal of being the fastest CAS ever. Having a polynomial module is a core concern and implementing a fast module also help in achieving a fast series module and other modules. Once implemented, SymEngine will be more capable as a fast optional SymPy core which we think is good to ship before 1.0 and at the same time SymEngine becomes a powerful CAS on it&#39;s own.</p>
<p>You can find the proposal <a href="https://github.com/sympy/sympy/wiki/GSoC-2015-Application-Sumith-:-Implementing-polynomial-module-in-CSymPy">here</a> for more detailed description of the project.</p>
<p>Looking forward to a great summer and times to follow.</p>