commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <>
Subject Re: [MATH] Re: Sparse matrices not supported anymore?
Date Sun, 13 Oct 2013 12:17:08 GMT

On Sun, 13 Oct 2013 00:41:00 -0700, Ted Dunning wrote:
> Commons math decided not to support sparse matrices due to the 
> difficulty
> of getting them just right.
> The problem is that 0 * Inf = NaN, not 0.  This means that for 
> floating
> point math, 0 * x = x is not a true identity.
> The problem really arises when the 0 in question could be either 
> stored as
> a 0 or not.  Not storing zeros is, of course, the hallmark and 
> calling card
> of sparse matrices because if you assume that the zero multiplication
> identity holds, you can avoid lots of arithmetic.
> Unfortunately, if the other matrix or vector has Inf in it, 
> multiplying by
> a sparse matrix where the corresponding element is missing gives a 0
> instead of NaN.  Moreover, the dot product gives a value instead of 
> NaN.
> This is very hard to fix and still retain the desirable speed 
> properties of
> sparse matrices.  You could imagine that you have a bitmap of all of 
> the
> Inf values in every matrix, but keeping that bitmap up to date can
> absolutely kill performance since you have the potential for a branch 
> in
> critical inner loops.
> Most sparse matrices just punt and say they are sorry in a very
> non-IEEE-754 sort of way.

How do they do that, practically?

> Commons Math has decided instead to remove sparse matrices entirely.

IIRC, this decision was taken by default, because nobody was identified
as a user of CM's sparse matrices implementation. We thus concluded 
it was harmless to drop this part of the code because it needed work 
issues clearly explained above) and we are lacking human resources to
perform it (i.e. we need developers interested to fix and maintain this
part of the code). If such a person would come forward, the decision
could probably be reverted.


> On Thu, Oct 10, 2013 at 6:34 AM, Daniel Marbach <> 
> wrote:
>> Hi,
>> Does Apache Commons support sparse matrices? I understand that the
>> interface SparseRealMatrix is deprecated...
>> Will there be a replacement or has the project decided to stop 
>> supporting
>> sparse matrices altogether?
>> Thanks,
>> Daniel

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message