13.07.2015 Views

computing the quartet distance between general trees

computing the quartet distance between general trees

computing the quartet distance between general trees

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.2. IMPLEMENTATION 51oretic approach.Mailund et al. [14] suggest <strong>the</strong> use of advanced matrix multiplication methods andsubstantiate <strong>the</strong>ir algorithmic results with <strong>the</strong> best <strong>the</strong>oretic result within <strong>the</strong> field ofmatrix multiplication, namely <strong>the</strong> Coppersmith-Winograd algorithm [7]. As mentionedin Chap. 1, this kind of <strong>the</strong>oretic result will be met with immediate scepticism by mostprogrammers, since one might suspect that <strong>the</strong> demands of <strong>the</strong> <strong>the</strong>ory can never be metby an implementation. In this case because of <strong>the</strong> size of <strong>the</strong> input being too small toobserve <strong>the</strong> improvement.Here <strong>the</strong> ideal situation would be to find an algorithm that is sub-cubic in <strong>the</strong>oryand still efficiently implemented in practice. Searching <strong>the</strong> literature and <strong>the</strong> web for areasonable method for matrix multiplication I came across <strong>the</strong> Strassen algorithm [18],which is approximately O(n 2.8 ) and is described as being efficient in practice for largematrices. However, I was not successful in finding an optimized implementation of <strong>the</strong>algorithm or a linear algebra library containing one. Since matrix multiplication is not<strong>the</strong> focus of this <strong>the</strong>sis, but ra<strong>the</strong>r a smaller piece in <strong>the</strong> algorithmic puzzle, <strong>the</strong> time didnot allow me to attempt implementing it on my own. In addition, it seems unreasonablethat I would be competitive with highly optimized libraries.Instead I decided to go with a highly optimized, reliable and robust library. This isa meaningful decision, since <strong>the</strong> goal of <strong>the</strong> <strong>the</strong>sis is to test <strong>the</strong> practical usefulness of<strong>the</strong> algorithm. What is <strong>the</strong> use of a <strong>the</strong>oretic result if it is not practically applicable? Thefinal choice was to use <strong>the</strong> Basic Linear Algebra Subprograms (BLAS) API 4 , which is a defacto standard for various linear algebra packages. Since my first implementation was inPython, BLAS caught my attention after discovering that it integrates with SciPy/NumPy,which is automatically compiled against <strong>the</strong> BLAS installation if present on <strong>the</strong> machine.Fur<strong>the</strong>rmore, <strong>the</strong> Boost.NumericBindings library 5 , provides a generic layer <strong>between</strong> <strong>the</strong>Boost.uBlas data types and <strong>the</strong> BLAS linear algebra routines in C++.The exact routines utilized are some level 3 BLAS calls for matrix-matrix multiplication.In NumPy and Boost.NumericBindings <strong>the</strong>se have <strong>general</strong> interfaces used through<strong>the</strong> calls C = dot(A,B) and void gemm(A,B,C) respectively. Both solutions require abit of setup using <strong>the</strong> right type of matrix container structure, but with <strong>the</strong> libraries thisis not difficult. I will not provide fur<strong>the</strong>r details, but merely refer to <strong>the</strong> code which isavailable (see App. B).To get an idea of how <strong>the</strong> performance improved, a comparison has been made of <strong>the</strong>four implementations used, namely <strong>the</strong> two used in <strong>the</strong> prototypes and <strong>the</strong> two BLAS in-4 The BLAS specification: http://www.netlib.org/blas/5 Boost.NumericBindings: http://svn.boost.org/svn/boost/sandbox/numeric_bindings-v1/libs/numeric/bindings/doc/index.html

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!