Skip to content

gosom/matrix-multiplication-benchmark

Repository files navigation

Matrix multiplication bechmark

I wanted to learn how to write modules for python in C++. In particular I wanted to learn how to use Boost.Python. I wanted a practical example to see how it can be used and to see a real example of the speed gains.

I found in the blog of Martin Thoma a benchmark between python vs java vs c++ for matrix multiplication using the naive algorithm. Here I will try to extend this benchmark by creating a python module in c++ and calling that module from python.

I wanted to do as fewer modification in the python code. In practice the only modification I did is that I imported the module I created and run a function standardMatrixProduct with the same arguments as the original python code.

The results are impressive for the effort I put. I just rewrite the function standardMatrixProduct in C++ and exposed it to python using the Boost.Python library.

Results

Here is a plot of the results: alt tag

###Comments I know that the matrix multiplication method is not the proper. Probably for the matrix multiplication problem if you use python you would use NumPy or a similar special library. The point here was to show how easy you can speedup your code using modules written in C++ using Boost.Python.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published