Rare vectors are when you have many values ββin the vector as zero. While a dense vector is when most of the values ββin the vector are nonzero.
If you need to create a sparse vector from the specified dense vector, use the following syntax:
Vector sparseVector = Vectors.sparse(4, new int[] {1, 3}, new double[] {3.0, 4.0});
source share