Archive for April, 2013
I was recently working on some MATLAB code with Manchester University’s David McCormick. Buried deep within this code was a function that was called many,many times…taking up a significant amount of overall run time. We managed to speed up an important part of this function by almost a factor of two (on his machine) simply by inserting two brackets….a new personal record in overall application performance improvement per number of keystrokes.
The code in question is hugely complex, but the trick we used is really very simple. Consider the following MATLAB code
>> a=rand(4000); >> c=12.3; >> tic;res1=c*a*a';toc Elapsed time is 1.472930 seconds.
With the insertion of just two brackets, this runs quite a bit faster on my Ivy Bridge quad-core desktop.
>> tic;res2=c*(a*a');toc Elapsed time is 0.907086 seconds.
So, what’s going on? Well, we think that in the first version of the code, MATLAB first calculates c*a to form a temporary matrix (let’s call it temp here) and then goes on to find temp*a’. However, in the second version, we think that MATLAB calculates a*a’ first and in doing so it takes advantage of the fact that the result of multiplying a matrix by its transpose will be symmetric which is where we get the speedup.
Another demonstration of this phenomena can be seen as follows
>> a=rand(4000); >> b=rand(4000); >> tic;a*a';toc Elapsed time is 0.887524 seconds. >> tic;a*b;toc Elapsed time is 1.473208 seconds. >> tic;b*b';toc Elapsed time is 0.966085 seconds.
Note that the symmetric matrix-matrix multiplications are faster than the general, non-symmetric one.
A friend of mine recently got hold of a Microsoft Surface Pro tablet and he let me have a play on it for a couple of hours. So, I installed Mathematica 9 and ran the benchmark. A screenshot of the result is below with the Surface’s result in blue. Not bad for a tablet!
Touch controlled Manipulates were a lot of fun too. If only I could run such things on my iPad as appeared to be promised in http://blog.wolfram.com/2012/02/17/a-preview-of-cdf-on-ipad/
My only other comment is that the Touch Cover is truly awful, reminding me of ye-olde ZX81, but I’ve been told that the Type Cover is much better
When I first started this blog, there were only really two methods by which readers could keep up with new content – by subscribing to the RSS feed or by regularly dropping by the site to see what’s new. Since then readers have steadily been requesting other ways to follow the blog and, for the most part, I have obliged. Here’s a list of current methods:
- Subscribe to the RSS feed
- Follow me on Twitter – I post every WR article to my twitter feed along with whatever else I find interesting. Twitter is also a great way of contacting me and is the social media platform on which I am most active.
- WalkingRandomly on Facebook – A small following compared to the other channels but useful to some it seems.
- Drop by the site whenever the mood strikes you
Welcome to the latest edition of A Month of Math Software where I look back over the last month and report on all that is new and shiny in the world of mathematical software. I’ve recently restarted work after the Easter break and so it seems fitting that I offer you all Easter Eggs courtesy of Lijia Yu and R. Enjoy!
General purpose mathematical systems
- The Python-based computer algebra system, Sage, is now at version 5.8. Take a look at http://www.sagemath.org/mirror/src/changelogs/sage-5.8.txt to see what’s new
- Version 17 of the commercial computer algebra system, Maple, has been released. There are many new features including new signal processing functions, massive performance enhancements and something completely new called The Möbius Project!
- Every six months we get a new MATLAB release and March brought us 2013a. I’m always made a little happier when The Mathworks reduce their toolbox count by combining products and this time they’ve come good by combining The Fixed-Point Toolbox and Simulink Fixed Point products into the new Fixed Point Designer . An overview of other changes can be found at http://www.mathworks.co.uk/company/newsroom/MathWorks-Announces-Release-2013a-of-the-MATLAB-and-Simulink-Product-Families.html
- The almost continuously updated Euler Math Toolbox is now at 21.5. As ever, all of the updates and improvements can be found at http://euler.rene-grothmann.de/Programs/Changes.html
- Magma is now at version 2.19-4.
MATLAB add-ons
- The multiprecision MATLAB toolbox from Advanpix has been upgraded to version 3.4.3.3431 with the addition of multidimensional arrays.
- The superb, free chebfun project has now been extended to 2 dimensions with the release of chebfun2.
GPU accelerated computation
- Magma is a GPU accelerated linear algebra library and there is now a beta version for the Intel Xeon Phi – http://icl.cs.utk.edu/magma/news/news.html?id=315
- Stream Computing are compiling a list of OpenCL wrappers for various platforms and languages.
- AccelerEyes have published a couple of articles demonstrating how to use their ArrayFire product to accelerate calculations using GPUs. In March they brought us Benchmarks and Financial.
- CuPoisson v1 has been released. “CuPoisson is a GPU implementation of the 2D fast Poisson solver using CUDA. The method solves the discrete Poisson equation on a rectangular grid, assuming zero Dirichlet boundary conditions. “
Statistics and visualisation
- Version 3.0 of R was released today! A major change is that full 64bit vector support is now enabled meaning the end to the 2 billion row limit in data frames…bring on the big data! Full details at https://stat.ethz.ch/pipermail/r-announce/2013/000561.html
- Pandas, the data-analysis package for Python, has had a major update. Version 0.11 includes lots of new stuff which you can read about at http://pandas.pydata.org/pandas-docs/dev/whatsnew.html
- Matplotlib, the standard mathematical plotting library for Python, has been updated to version 1.2.1. This is just a bug-fix release; all the new user-visible functionality came in v1.2 which you can read about here.
- GNUPlot, the venerable plotting package from from the GNU Project, has been updated to version 4.6.2. A complete list of changes is at http://www.gnuplot.info/announce_4.6.2.txt
- A new version of the Perl Data Language (PDL) has been made available. See what’s new in version 2.006 at http://mailman.jach.hawaii.edu/pipermail/perldl/2013-March/007803.html
- Statisticsblog.com have reviewed the R-Link package in Mathematica 9 that allows you to integrate R and Mathematica code.
Finite elements
- Version 7.3 of deal.II is now available. deal.II is a C++ program library targeted at the computational solution of partial differential equations using adaptive finite elements.