Matteo Riondato created MATH-1639:
-------------------------------------
Summary: OpenMapRealMatrix can't have more than Integer.MAX_VALUE
*possible* entries
Key: MATH-1639
URL: https://issues.apache.org/jira/browse/MATH-1639
Project: Commons Math
Issue Type: Improvement
Reporter: Matteo Riondato
If one tries to create an OpenMapRealMatrix with a {_}possible{_}, i.e.,
{_}maximum{_}, number of entries greater than Integer.MAX_VALUE, the
constructor throws a NumberIsTooLargeException.
This behavior seems to be caused by the fact that the key of an entry in the
matrix is represented as an int, because an OpenIntToDoubleHashMap is used to
store the entries.
Thus, for example, it is not possible to create a OpenMapRealMatrix with ...
rows and columns and a single non-zero entry, which would be a perfectly fine
sparse matrix.
The choice of using int as the key type of the map to store the entries of the
matrix seems to severely limit the use of Commons Math for sparse matrices. If
one used a "standard" java.util.Map with a key type that could represent the
pair (row, column), then OpenMapRealMatrix would be much more useful.
Alternative, one wonders whether it would be possible to have an
OpenPairOfIntsToDoubleHashMap class.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)