mikera / vectorz-clj

Fast matrix and vector maths library for Clojure - as a core.matrix implementation
203 stars 19 forks source link

Exception creating a sparse array #57

Closed lambda-ai closed 8 years ago

lambda-ai commented 8 years ago

Hi, I'm running into an ArrayIndexOutOfBoundsException when trying to create a sparse-array. These are the versions I use (latest stable at this moment): [net.mikera/core.matrix "0.52.0"] [net.mikera/vectorz-clj "0.44.0"]

When I read the edn data from the attached zip file, and try to create a sparse-array, I get an exception:

> (def fd (read-string (slurp "failing-data.edn")))
> (m/sparse-array fd)
ArrayIndexOutOfBoundsException 8498  mikera.vectorz.impl.AStridedVector.getElements (AStridedVector.java:306)

It's not due to the matrix not being rectangular (although even non-rectangular seems to be supported):

> (distinct (map count fd))
(128)

Are there some restrictions on the creation of sparse-arrays? I didn't see any in the docs. If not, I assume this is a vectorz-clj issue, rather than a core.matrix issue.

Thanks, -Mathias

failing-data.zip

mikera commented 8 years ago

Had a quick look at this and it does indeed appear to be a subtle vectorz-clj bug during construction of sparse arrays. Will take a more detailed look.

mikera commented 8 years ago

I tracked down the bug. This is now fixed in latest Vectorz develop branch, will be fixed in next vectorz-clj release (hopefully soon)

lambda-ai commented 8 years ago

Thanks for the super-fast fix!