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. Commons Math has decided instead to remove sparse matrices entirely. On Thu, Oct 10, 2013 at 6:34 AM, Daniel Marbach <[email protected]> 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 >
