Thursday, April 25, 2013

la4j's performance


Recently, I've bumped into this web-site. I was quite surprised that they used la4j for benchmarking (see demo video). It is always pleasure to see when people use your 'just-for-fun' library. Anyway, I didn't except that la4j is so slow. I wrote an email to the guys who was testing la4j and ask them to provide me benchmark sources. So, the sources was looking good and there is nothing I can do there to improve la4j's performance. But something, I already did.

They was testing la4j-0.3.0 and it is much slower than a current 0.4.0 version. I've done several significant improvements, that speeded up whole the library.

First of all, I've rewrote sparse matrices to use binary search instead of linear one. Binary search works for logarithmic time O(log n) and if gives me up to 2.2x speed up for get/set operations.

The other good thing that I did - is improvement matrix-by-matrix multiply algorithm. I've speeded it up to 3x for dense matrices and up to 11x for sparse ones.

Here is some numbers that I got today. Performnace of matrix-by-matrix multiply:

la4j-0.3.0 Basic1DMatrix(1000x1000) - 3784ms
la4j-0.3.0 Basic2DMatrix(1000x1000) - 3946ms

la4j-0.3.0 CRSMatrix(500x500) - 45897ms
la4j-0.3.0 CCSMatrix(500x500) - 219312ms

la4j-0.4.0 Basic2DMatrix(1000x1000) - 1476ms
la4j-0.4.0 Basic1DMatrix(1000x1000) - 1489ms

la4j-0.4.0 CRSMatrix(500x500) - 20245ms
la4j-0.4.0 CCSMatrix(500x500) - 12413ms

The new version of la4j - version 0.4.0 will be avaliable this summer. It is currently avaliable at it's GitHub page: https://github.com/vkostyukov/la4j

Monday, March 18, 2013

Safe and unsafe matrices/vectors

There are was an ugly methods in la4j that started with "unsafe_". So, I've added these methods to provide to the client more effective and raw mechanisms on matrices and vectors. Anyway, I've decided to replace with method by new matrix type - SafeMatrix. The thing is all matrices in la4j are unsafe by default, but if client wants to get safe matrix, he can use special matrix wrapper that wraps unsafe methods with additional checks. Actually, there is another way to do that - introduce new matrix classes (use inheritance) but everybody knows that it prefer to use composition instead of inheritance.

So, the la4j looks more strict and clear now and I feel this is the right way to develop the library.

Just brief exaple of using safe and unsafe matrices:

Matrix a = new Basic1DMatrix(..); // unsafe
Matrix b = a.safe(); // safe
Matrix c = a.multyply(b, Matrices.SAFE_BASIC1D_FACTORY); // safe

And friendly reminder: if someone want to participate - there are loads of opened issues at GitHub.

http://la4j.org

Monday, January 28, 2013

Good news from la4j!

There are several good news from me about la4j.

1. la4j accepted an awesome pull-request from Evgenia Krivova with implementation of rank() method.

2. I've converted all TODO's from code to GitHub issues, so if you want to contibure la4j, plase follow the issues list.

3. Today la4j got the first bugreport submitted by user through GitHub interface.

Just a friendly reminder: https://github.com/vkostyukov/la4j

Wednesday, December 26, 2012

la4j-0.3.0 is out!

I am proud to announce that la4j-0.3.0 is ready for download now.

Here is release notes for version 0.3.0. BTW, this is the lagest changelog in the history of project.
  • la4j got new API and new package naming (starting with "org.la4j.*")
  • la4j has been moved from Google Code to GitHub;
  • la4j uses Travis-CI;
  • la4j available through Maven now;
  • support of new matrices types (Basic1DMatrix, CCSMatrix);
  • new I/O API and format - Symbol Separated Stream (CSV, TSV, etc.);
  • new la4j entities: matrix/vector sources, matrix/vector functors;
  • la4j uses default unchecked exceptions from java.lang.* now;
  • the code has been formated according to JavaCodeConv;
  • support of unsafe accessors and arithmetic methods;
  • support Eigenvalues decomposition for non-symmetric matrix;
  • new fast matrix-to-matrix multiply algorithm with blocks;
  • new algorithm for runtime-based machine epsilon initialization;
  • fixed several major/critical bugs;
If you like la4j-0.3.0, please drop me a note in twitter: @vkostyukov

Links

http://la4j.org
https://github.com/vkostyukov/la4j

PS: I've decided to use Google Code Downloads for the hosting of binary files. The main reason for this is available out-of-the-box download counter. I want to see the output of my work.


Wednesday, December 19, 2012

la4j at GitHub now!

I've decided to move la4j sources from Google Code to GitHub. I think this is the right desidion. First of all, I got free CI service called Travis-CI. Secondly, GitHub provides the best instruments to open source collabaration. I hope GitHub features helps developers to involve into la4j development proccess.

Here is new repository page: https://github.com/vkostyukov/la4j. Feel free to star it, fork it and send pull-requests :)

BTW, everything is going according to the plan. So, I'll release la4j-0.3.0 at 31th of December.

Have a nice hollidays!

Wednesday, December 12, 2012

New Year Gift: la4j 0.3.0

I'm currently planing to release the new version of la4j for 31 of December. It'll be a NY Gift for la4j users.

The goog news is I got a lot of messages from people who want to contribute to la4j. Many of them, already sent me a patches and this is awesome! So, I guess we can move la4j to version 0.3.0 together.

Again, I'm no prommise that I'll finish all tasks, but I'll try! Wish me luck :)

Friday, August 31, 2012

la4j gets the first contrututor

Good news, everyone!

La4j gets the first contribution by Wajdy Essam. He has written missed methods in Basic1DMatrix class. I hope Wajdy will continue work with that class to increase performance and code readability.

BTW, I've also added 'Contributors' section into README file and updated all source headers.