That class in primarily used as a delegate to other implementation, but it's perfectly fine to use it directly. Probably the most direct solution in this case is to do:
array_sum = lhCounts.nonzeros().stream().mapToDouble(nz -> nz.doubleValue()).sum();
There is also the possibility to create an Array1D instead. It has a richer api. Then you can do it this way:
Array1D<Double> lhCounts1D = Array1D.PRIMITIVE64.makeSparse(dim);
array_sum = lhCounts1D.aggregateAll(Aggregator.SUM);
The nonzeros-stream is also available in this case
array_sum = lhCounts1D.nonzeros().stream().mapToDouble(nz -> nz.doubleValue()).sum();
and if that "array" is actually something 2-D or N-D you can create an Array2D or ArrayAnyD instead.
Array2D<Double> lhCounts2D = Array2D.PRIMITIVE64.makeSparse(dim, dim);
ArrayAnyD<Double> lhCountsAnyD = ArrayAnyD.PRIMITIVE64.makeSparse(dim, dim, dim, dim);
The Array1D, Array2D and ArrayAnyD api:s were designed for dense structures. The ability to instantiate them as sparse was added at a later point. Some things you can do with them may not be very efficient in the sparse case. You can even do plain stupid things like hugeSparseArray.fillAll(1.0)
;