Speed bottleneck found and fixed. Using a HashMap approach for sparse representation, otherwise we could use the la4j package which provides sparse data structures.