[SPARK-4409] Modified genRandMatrix