Description
Large values of n or k in EigenValueDecomposition.symmetricEigs will fail with a NegativeArraySizeException. Specifically, this occurs when 2*n*k > Integer.MAX_VALUE. These values are currently unchecked and allow for the array to be initialized to a value greater than Integer.MAX_VALUE. I have written the below 'require' to fail this condition gracefully. I will submit a pull request.
require(ncv * n.toLong < Integer.MAX_VALUE, "Product of 2*k*n must be smaller than " +
s"Integer.MAX_VALUE. Found required eigenvalues k = $k and matrix dimension n = $n")
Here is the exception that occurs from computeSVD with large k and/or n:
Exception in thread "main" java.lang.NegativeArraySizeException
at org.apache.spark.mllib.linalg.EigenValueDecomposition$.symmetricEigs(EigenValueDecomposition.scala:85)
at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeSVD(RowMatrix.scala:258)
at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeSVD(RowMatrix.scala:190)