TensorFactory_F32 { public static Tensor_F32 randomMM( Random rand , boolean subTensor , float min , float max , int ...shape ) { Tensor_F32 out = zeros(subTensor?rand:null,shape); randomMM(rand,min,max,out); return out; }  static Tensor_F32 zeros( Random rand, int ...shape ); static Tensor_F32 random(Random rand , boolean subTensor , int ...shape ); static Tensor_F32 randomMM( Random rand , boolean subTensor , float min , float max , int ...shape ); static List<Tensor_F32> randomMM(Random rand , boolean subTensor , float min , float max , List<int[]> shapes ); static void randomMM( Random rand , float min , float max , Tensor_F32 tensor );  }
@Test public void randomMM() { for( boolean sub : new boolean[]{false,true}) { Tensor_F32 tensor = TensorFactory_F32.randomMM(rand, sub, -1,1, 4, 3, 2); assertEquals(4, tensor.length(0)); assertEquals(3, tensor.length(1)); assertEquals(2, tensor.length(2)); assertEquals(sub, tensor.isSub()); int N = tensor.length(); float sum = 0; for (int i = 0; i < N; i++) { float v = tensor.getAtIndex(i); assertTrue(v != 0); sum += v; } assertTrue(Math.abs(sum) < 4*3*2/2.0f); } }