SPARK-3803 [MLLIB] ArrayIndexOutOfBoundsException found in executing computePrincipalComponents

Avoid overflow in computing n*(n+1)/2 as much as possible; throw explicit error when Gramian computation will fail due to negative array size; warn about large result when computing Gramian too