One of the weakest side of the la4j library - its documentation. I would really appreciate any help in this direction. It's not that difficult to fill the gaps in current documentation. It just requires some time and motivation on contribute to OSS project. So, if you folks, were always dreaming of OSS contribution - drop me the message @vkostyukov. We will work it out.
Monday, January 27, 2014
Sunday, January 26, 2014
Vector distance and norm in la4j
The la4j API allows you to calculate the vector norm easily with appropriate vector accumulator. There are three norm accumulators available: Euclidean, Manhattan and Infinity. So, you can use them as
fold arguments in a way like this:Vector a = new BasicVector(new double[]{ 1.0, 2.0, 3.0 });
doble norm0 = a.fold(Vectors.mkEuclideanNormAccumulator()); // Euclidean Norm
doble norm1 = a.fold(Vectors.mkManhattanNormAccumulator()); // Manhattan Norm
doble normMax = a.fold(Vectors.mkInfinityNormAccumulator()); // Infinity Norm
When norm is available, the distance between two vectors can be calculated as:
Vector a = new BasicVector(new double[]{ 1.0, 2.0, 3.0 });
Vector b = new BasicVector(new double[]{ 4.0, 5.0, 6.0 });
// the distance between vectors 'a' and 'b' in terms of Manhattan space
double distance = a.subtract(b).fold(Vectors.mkManhattanNormAccumulator());
You also can use norm in order to normalize the vector's components:
Vector a = new BasicVector(new double[]{ 1.0, 2.0, 3.0 });
double norm = a.fold(Vectors.mkEuclideanNormAccumulator());
// normalize 'b' in terms of Eucludean space
Vector b = a.divide(norm);
Saturday, January 25, 2014
New release: v0.4.9!
The new version of la4j (Linear Algebra for Java) is available: 0.4.9! This awesome release is made through the effort of active contributors: Michael, Phil, Anveshi, Clement, Miron and Todd. Together, we pushed 95 new commits and made a significant progress with big sparse matrices. Here is the full list of changes:
- Bug fix in
align()method for big sparse matrices (reported by Michael Kapper) - Bug fix in
growup()method for big sparse matrices (contributed by Phil Messenger) - Bug fix in
MatrixMarketStream - New matrix method
select()(contributed by Anveshi Charuvaka) - New vector method
select() - Bug fix in
growup()method for the case with positive overflow (contributed by Clement Skau) - New matrix predicate
Matrices.SQUARE_MATRIX(contributed by Miron Aseev) - New matrix predicate
Matrices.INVERTIBLE_MATRIX(contributed by Miron Aseev) - New vector method
norm(NormFunction)that implements p-norm support (contributed by Miron Aseev) - New matrix predicate
PositiveDefiniteMatrix(contributed by Miron Aseev) - Bug fix in
each,eachInRow,eachInColumnmethods of sparse matrices (reported by Leonid Ilyevsky) - New matrix methods:
foldColumnsandfoldRows(contributed by Todd Brunhoff) - New matrix methods:
assignRowandassignColumn - New matrix methods:
updateRowandupdateColumn - New matrix methods:
transformRowandtransformColumn
Don't forget to update your Maven artefacts and feel free to touch me with feedbacks/questions at @vkostyukov!
Tuesday, October 1, 2013
The la4j-0.4.5 has been released!
I am happy to anounce that la4j-0.4.5 has just been released!
I feel so proud about this release. We did a fantastic job together: 7 developers pushed 292 commits to master branch and much more:
- 35 issues has been closed
- 30 pull request has been merged
- +262 new tests: 581 in totall
- +6k LOC: 22k in totall
All the major functional and performance issues has been fixed. The la4j did a great progress according to the previous versions. We did our best and hope you will enjoy new version!
References
http://la4j.org/ - project web page
https://github.com/vkostyukov/la4j - GitHub page
https://github.com/vkostyukov/la4j/releases/tag/v0.4.5 - GitHub's release page
Tuesday, September 10, 2013
Meet the new la4j contributors
The la4j now almost ready for 0.4.5 release. All our current activities are dealing with testing. We want to make new version as stable as possible. For this we have already added 150 new tests and planning to add 50-100 more. Thus the new release will contain ~500-550 tests in total, which is the great progress according to the previous release.
Traditionally, I would like to thank two guys: Yuriy Drozd (Kiev, Ukraine) and Maxim Samoylov (Saint-Petersburg, Russia) for being such an active and valuable contributors of la4j. These guys did a wonderful job to bring the la4j to current state. Yuriy has fixed a critical issue in 'swap' operation for sparse vectors and added a new decomposition support to la4j.
Maxim joined the project two months ago and started working on stability of existing code. Hi has fixed a very important issue in Eigen dcompositor; added new interator (iterating through non-zero values, iterating through the values in row/column) methods to matrix class. Maxim has also spent tons of time evaluating double-rounding issues in la4j (in "rank" and "determinant" methods). So, Maxim now is the most active contributor, for sure. He made 56 commits (+2000 LOC) to repository and got the second place (right after me) in contributors list (see picture bellow).
Thank you again, guys! I really appreciate your help!
Thursday, August 1, 2013
SODD - Stack-Overflow Driven Development
I use this methodology in the la4j. The idea is quite a simple:
1. Go to SO and find the questions related to your project (tags "matrix", "java" for la4j).
2. Try to understand what exactly users want to do. And how do they want to do that.
3. Implement new functionality according to the user's questions.
Here is the good example of the question that forced me to add new functionality - accumulator functions.
1. Go to SO and find the questions related to your project (tags "matrix", "java" for la4j).
2. Try to understand what exactly users want to do. And how do they want to do that.
3. Implement new functionality according to the user's questions.
Here is the good example of the question that forced me to add new functionality - accumulator functions.
Wednesday, July 24, 2013
A Parallel Linear Algebra Library
When I started the la4j project, I didn't think that it will be one of the most popular packages for Linear Algebra in Java. So, in two years the library changed a lot. And it continue changes from day to day. I'm so glad seeing people fixing bugs/proposing pull-request/sending feedbacks. Which means, that I need to make this library more and more awesome. And I have a plan to bring the la4j into the parallel world.
This plan conststs of two major steps. First, I need to design a high-level idea of incapsulating the engine of the library, whcih knows how to deals with matrices and vectros in a more efficient way. The engine should use all the advantages of concreet matrix type and don't use its disadvantages. The simpliest example - do not iterate through zero elements in CRS/CCS matrices while computing something that doesn't require handling zero values. I hope, it can be done in realease 0.5.0 at this winter. And I believe that this version will show just incredible performance accoring to the 0.4.5, because all these optimizations with sparse matrices. But it is still wll be a single-threaded version of la4j's engine. Second, I'm planing to develop an additional implementation of engine, that will handles all tasks in parallel - a parallel engine. And I'm really exited about new features of Java's Fork-Join Framework. It just a perfect base/tool for solving this kind of tasks. So, A parallel engine will be avaliable at version 0.6.0 at next summer.
The F-J Framework is an awesome and well-tuned cuncurrent framework for Java. And it allows to the developer use data-parallelism in his code. This is just perfect for matrix operations.
PS: I'm planning to keep the la4j's API unchanged. This is my goal.
If someone wants to participate in discussion the engine's design, go there.
This plan conststs of two major steps. First, I need to design a high-level idea of incapsulating the engine of the library, whcih knows how to deals with matrices and vectros in a more efficient way. The engine should use all the advantages of concreet matrix type and don't use its disadvantages. The simpliest example - do not iterate through zero elements in CRS/CCS matrices while computing something that doesn't require handling zero values. I hope, it can be done in realease 0.5.0 at this winter. And I believe that this version will show just incredible performance accoring to the 0.4.5, because all these optimizations with sparse matrices. But it is still wll be a single-threaded version of la4j's engine. Second, I'm planing to develop an additional implementation of engine, that will handles all tasks in parallel - a parallel engine. And I'm really exited about new features of Java's Fork-Join Framework. It just a perfect base/tool for solving this kind of tasks. So, A parallel engine will be avaliable at version 0.6.0 at next summer.
The F-J Framework is an awesome and well-tuned cuncurrent framework for Java. And it allows to the developer use data-parallelism in his code. This is just perfect for matrix operations.
PS: I'm planning to keep the la4j's API unchanged. This is my goal.
If someone wants to participate in discussion the engine's design, go there.
Saturday, July 20, 2013
JavaDoc for la4j
Great news everyone!
I've pushed initial version of la4's javadoc at offisial site: http://la4j.org/apidocs/.
I'm planning to keep the docs updated as much as possible.
I've pushed initial version of la4's javadoc at offisial site: http://la4j.org/apidocs/.
I'm planning to keep the docs updated as much as possible.
Friday, July 12, 2013
Six bugs per person
I was thinking about the way how can I pay back to the la4j's contributors. And the first thing that comes into y mind was just posting a short blog message about their work in the project. It is not a big deal for me, but I believe that it might be pleased for the contributors.
So, I've already wrote two posts about two valuable contributors (here and here). Now, I'm going to tell you about the third la4j's contributor who spent loads of his time trying to make la4j more stable and predictable. I'm talking about Ewald Grusk. Ewald fixed 3 bugs by himself (one, two, three), reported about 3 bugs (one, two, three) and proposed a pull-request with minor improvements.
I'm really appreciate what everyone does for la4j. And Ewald did just a fantastic job. He is definitely the most active contributor in the history of the project. Ewald, if I had a chance, I would buy you a beer :)
So, I've already wrote two posts about two valuable contributors (here and here). Now, I'm going to tell you about the third la4j's contributor who spent loads of his time trying to make la4j more stable and predictable. I'm talking about Ewald Grusk. Ewald fixed 3 bugs by himself (one, two, three), reported about 3 bugs (one, two, three) and proposed a pull-request with minor improvements.
I'm really appreciate what everyone does for la4j. And Ewald did just a fantastic job. He is definitely the most active contributor in the history of the project. Ewald, if I had a chance, I would buy you a beer :)
Wednesday, July 3, 2013
New matrix operations: shuffle and rotate
The la4j (Linear Algebra for Java) has recently got two pull-requests (#48, #50) by Jakob Moellers, who implemented two new methods in
The
The
Matrix interface. Jakob added support for shuffle() (also works for vectors) and rotate() methods. Here is the brief introduction into these methods.
The
Matrix.rotate() method is pretty simple. It rotates the matrix by 90 degrees. Here is the example:
Matrix a = new Basic1DMatrix(new double[][] {
{ 1.0, 2.0 },
{ 3.0, 4.0 }
});
/*
Matrix {
3.0, 1.0
4.0, 2.0
}
*/
Matrix b = a.rotate();
The
shuffle() method can be used with matrices as well as with vector. It shuffles the element of matrix or vector by using Fisher-Yates algorithm. Here is the example.
Matrix a = new Basic1DMatrix(new double[][] {
{ 1.0, 2.0, 3.0 },
{ 4.0, 5.0, 6.0 }
});
/*
Matrix {
3.0, 5.0, 4.0
6.0, 1.0, 2.0
}
*/
Matrix b = a.shuffle();
Vector c = new CompressedVector(new double[] { 1.0, 2.0, 3.0 });
// Vector { 2.0, 3.0, 1.0 }
Vector d = c.shuffle();
Thanks Jakob for the great job!
Thursday, June 27, 2013
Vector Algebra in la4j
All Vector Algebra methods in la4j were completely messed up. That was my fault. I've spent loads of time improving core la4j's primitive - it's matrices. But, good news here, that Daniel Renshaw caught all this mess and proposed a pull-request with changes. Thanks Daniel! This is such a great example of how do the open source world live. So, I'll try to introduce you new features of la4j's
The la4j now supports Inner Product (Dot Product). It was previously implemented by
There is also a Hadamard Product (element-wise product), which was implemented in
The la4j also supports Outer Product, which produces a matrix as result (was not supported previously).
So, all these things allow do not care about vector's orientation (row-vector/column-vector). Just use vector class when you need it. The la4j does all the work for you. It automatically determine by context whether the vector is a row-vector or a column-vector.
Vector class.
The la4j now supports Inner Product (Dot Product). It was previously implemented by
Vector.product(Vector) method:
Vector a = new BasicVector(new double[]{ 1.0, 2.0, 3.0 });
Vector b = new BasicVector(new double[]{ 4.0, 5.0, 6.0 });
double d = a.innerProduct(b); // 1.0*4.0 + 2.0*5.0 + 3.0*6.0 = 32
There is also a Hadamard Product (element-wise product), which was implemented in
Vector.multiply(Vector).
Vector a = new BasicVector(new double[]{ 1.0, 2.0, 3.0 });
Vector b = new BasicVector(new double[]{ 4.0, 5.0, 6.0 });
Vector c = a.hadamardProduct(b); // Vector { 4.0, 10.0, 18.0 }
The la4j also supports Outer Product, which produces a matrix as result (was not supported previously).
Vector a = new BasicVector(new double[]{ 1.0, 2.0, 3.0 });
Vector b = new BasicVector(new double[]{ 4.0, 5.0, 6.0 });
/*
Matrix {
4.0, 5.0, 6.0
8.0, 10.0, 12.0
12.0, 15.0, 18.0
}
*/
Matrix c = a.outerProduct(b);
So, all these things allow do not care about vector's orientation (row-vector/column-vector). Just use vector class when you need it. The la4j does all the work for you. It automatically determine by context whether the vector is a row-vector or a column-vector.
Saturday, June 1, 2013
la4j-0.4.0 is here!
I'm proud to announce that la4j is perfectly ready for releasing version 0.4.0. This is another huge step for such a small project like la4j. It took me 6 month to prepare la4j for new version. I've done loads of work: rewrote 50% of sources and added ~5k loc of new functionality.
So, I've decided to tell you about how many interesting things are happed to me in this period of development. I've got several positive feedbacks from people about la4j. I'm so glad that pople enjoy it. I've got several awesome pull-request to la4j from Russia, Italy, USA. Thank you guys for a wonderful job!
I've bumped in the fact that people from business use la4j as competitor for their products. They used version 0.3.0 and it was realy slow. So, I did some optimizations and new version realy flies!
And the last thing. Recently, I've read awesome book about genius physicist Richard Feynman. One of its chapter describes scientific laboratory of Los-Alamos, where he worked on Manhattan project. So, I was so excited about this laboratory and pople working there. You can imagine now, what I was feeling when I've found the line "los alamos national laboratory" in www.la4j.org's visitors log.
The changelog for new version (the huges changelog in the history of la4j):
So, I've decided to tell you about how many interesting things are happed to me in this period of development. I've got several positive feedbacks from people about la4j. I'm so glad that pople enjoy it. I've got several awesome pull-request to la4j from Russia, Italy, USA. Thank you guys for a wonderful job!
I've bumped in the fact that people from business use la4j as competitor for their products. They used version 0.3.0 and it was realy slow. So, I did some optimizations and new version realy flies!
And the last thing. Recently, I've read awesome book about genius physicist Richard Feynman. One of its chapter describes scientific laboratory of Los-Alamos, where he worked on Manhattan project. So, I was so excited about this laboratory and pople working there. You can imagine now, what I was feeling when I've found the line "los alamos national laboratory" in www.la4j.org's visitors log.
The changelog for new version (the huges changelog in the history of la4j):
- Up to 2x performance improvement of sparse entries (binary search power)
- Performance improvement for matrix-by-matrix multiply algorithm (3x for dense, 11x for sparse)
- New matrix method `rank()` (contributed by Evgenia Krivova)
- New fast implementation of `determinant()` method
- New method `update()` (as compound operator replacement)
- Matrices are unsafe by default (new corresponding methods `safe()` and `unsafe()`)
- New method `slice()`
- New method for `kronecker()` product
- Support map-reduce approach by method pair `transform()` and `fold()`
- New matrices and vectors sources that handles IO streams
- Support of building a constant matrix in factories
- Matrices and vectors are immutable in terms of dimension
- Sparse entities are self-clearing (no memory leaks)
- Support vector-by-matrix multiplication
- Bug fix in `MatrixDecFunction`
- Bug fix in `MatrixMatketStream` (contributed by Alessio Placitelli)
- Bug fix in matrix-to-vector multiplication (contributed by Pavel Kalaidin)
- Bug fix in `align()` method (contributed by Chandler May)
- But fix in `QRDecompositor`
References:
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) - 1489msla4j-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
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
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.
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.
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;
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!
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 :)
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.
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.
Thursday, July 26, 2012
la4j.org - official web-site
Yesterday, I've registered new domain for la4j -http://la4j.org. I've also wrapped all sources in "org" package. So, now all imports looks like "import org.la4j.matrix.Matrix".
BTW, I created repository on GitHub with web-site sources: https://github.com/vkostyukov/www.la4j.org
BTW, I created repository on GitHub with web-site sources: https://github.com/vkostyukov/www.la4j.org
Subscribe to:
Posts (Atom)

