def rand(seed:Int):Double={ val rand=new Random(seed) rand.nextDouble()} def rand2(size:Int,seed:Int):SparseVector={ val rand=new Random(seed) val ret_indices=Array.range(0,size) val ret_values=Array.tabulate[Double](size)(i=>rand.nextDouble()) //从函数…