You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Luc Maisonobe <Lu...@free.fr> on 2008/12/20 01:29:56 UTC

[math] new DenseRealMatrix

luc@apache.org a écrit :
> Author: luc
> Date: Fri Dec 19 15:59:38 2008
> New Revision: 728185
> 
> URL: http://svn.apache.org/viewvc?rev=728185&view=rev
> Log:
> added a new DenseRealMatrix class intended to replace RealMatrixImpl
> this class is more cache-friendly as it stores data from squares blocks
> in flattened arrays. This allows algorithms that need cross-direction
> navigation like multiplication or transpose) to be more efficient on
> modern processors.
> 
> Added:
>     commons/proper/math/trunk/src/java/org/apache/commons/math/linear/DenseRealMatrix.java   (with props)
>     commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java   (with props)
> Modified:
>     commons/proper/math/trunk/src/java/org/apache/commons/math/linear/MatrixUtils.java
>     commons/proper/math/trunk/src/test/org/apache/commons/math/linear/MatrixUtilsTest.java

This new class is part of the ongoing work to improve again the
performances of the linear algebra package. It addresses an issue raised
by Ted some weeks ago about the basic storage used by RealMatrixImpl,
which is a simple double[][] with a direct mapping for for rows and
columns (i.e. m(i, j) is stored in m.data[i][j]).

The new DenseRealMatrix tries to be more cache-friendly. The matrix is
split in square blocks (32x32 blocks currently) except the blocks on the
right and bottom sides which may be smaller. Each block is flattened in
row major order in an array. These arrays are therefore 1024 elements
long for regular blocks, and smaller for  border blocks. Most algorithms
can be organized to process each block completely before needing to load
the next block in memory. This is were the performance gain occurs.

I have implemented only some of the basic algorithms yet (addition,
subtraction, multiplication, transpose, extraction of submatrix). I will
continue this work for most of the methods from the RealMatrix
interface, and also for the various decomposition classes.

If some of you want to have a look at this class, I'll appreciate any
comments.

Luc

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [math] new DenseRealMatrix

Posted by Ted Dunning <te...@gmail.com>.
Interesting approach.  I will be real interested in hearing your results
with this compared to the traditional row or column major storage mode.



On Fri, Dec 19, 2008 at 4:29 PM, Luc Maisonobe <Lu...@free.fr>wrote:

> ... <lu...@apache.org>The new DenseRealMatrix tries to be more
> cache-friendly. The matrix is
> split in square blocks (32x32 blocks currently) except the blocks on the
> right and bottom sides which may be smaller. Each block is flattened in
> row major order in an array. These arrays are therefore 1024 elements
> long for regular blocks, and smaller for  border blocks. Most algorithms
> can be organized to process each block completely before needing to load
> the next block in memory. This is were the performance gain occurs.
>
>