Tensor implements Serializable { public final float get(final int idx) { return values[idx]; } Tensor(final float... values);  Tensor(final float[][] vals);  Tensor(final float[][][] vals);  Tensor(final float[][][][] vals);  Tensor(int cols);  Tensor(int cols, float val);  Tensor(int rows, int cols);  Tensor(int rows, int cols, float[] values);  Tensor(int rows, int cols, int depth);  Tensor(int rows, int cols, int depth, int fourthDim);  Tensor(int rows, int cols, int depth, float[] values); private  Tensor(Tensor t); final float get(final int idx); final float set(final int idx, final float val); final float get(final int row, final int col); final void set(final int row, final int col, final float val); final float get(final int row, final int col, final int z); final void set(final int row, final int col,  final int z, final float val); final float get(final int row, final int col, final int z, final int fourth); final void set(final int row, final int col, final int z, final int fourth, final float val); final float[] getValues(); final void setValues(float... values); final void copyFrom(float[] src); final int getCols(); final int getRows(); final int getDepth(); final int getFourthDim(); final int getDimensions(); @Override String toString(); final void add(final int row, final int col, final float value); void add(final int row, final int col, final int z, final float value); final void add(final int row, final int col, final int z, final int fourth, final float value); final void add(final int idx, final float value); final void add(Tensor t); final void sub(final int row, final int col, final float value); final void sub(final int row, final int col, final int z, final float value); final void sub(final int row, final int col, final int z, final int fourth, final float value); final void sub(final Tensor t); final static void sub(final Tensor t1, final Tensor t2); final void div(final float value); final void fill(final float value); static final void fill(final float[] array, final float val); static void div(final float[] array, final float val); static final void sub(final float[] array1, final float[] array2); static final void add(final float[] array1, final float[] array2); static final void copy(final Tensor src, final Tensor dest); static final void copy(final float[] src, final float[] dest); @Override boolean equals(Object obj); boolean equals(Tensor t2, float delta); static Tensor zeros(int cols); static Tensor ones(int cols); static String valuesAsString(Tensor[] tensors); void setValuesFromString(String values); static Tensor create(int rows, int cols, float[] values);  }
@Test public void testGet_int() { int idx = 2; Tensor instance = new Tensor(new float[] {0.1f, 0.2f, 0.3f, 0.4f}); float expResult = 0.3F; float result = instance.get(idx); assertEquals(expResult, result, 0.0); }
@Test public void testGet_int_int() { int row = 1; int col = 2; Tensor instance = new Tensor(new float[][] {{0.11f, 0.12f, 0.13f}, {0.21f, 0.22f, 0.23f}}); float expResult = 0.23f; float result = instance.get(row, col); assertEquals(expResult, result, 0.0); }
@Test public void testGet_3args() { int row = 1; int col = 2; int z = 1; Tensor instance = new Tensor(new float[][][] { {{0.111f, 0.121f, 0.131f, 0.141f}, {0.211f, 0.221f, 0.231f, 0.241f}, {0.311f, 0.321f, 0.331f, 0.341f}}, {{0.112f, 0.122f, 0.132f, 0.142f}, {0.212f, 0.222f, 0.232f, 0.242f}, {0.312f, 0.322f, 0.332f, 0.342f}}}); float expResult = 0.232f; float result = instance.get(row, col, z); assertEquals(expResult, result, 0.0); }
@Test public void testGet_4args() { Tensor instance = new Tensor(new float[][][][] { {{{0.1111f, 0.1121f, 0.1131f, 0.1141f}, {0.1211f, 0.1221f, 0.1231f, 0.1241f}, {0.1311f, 0.1321f, 0.1331f, 0.1341f}}, {{0.1112f, 0.1122f, 0.1132f, 0.1142f}, {0.1212f, 0.1222f, 0.1232f, 0.1242f}, {0.1312f, 0.1322f, 0.1332f, 0.1342f}}}, {{{0.2111f, 0.2121f, 0.2131f, 0.2141f}, {0.2211f, 0.2221f, 0.2231f, 0.2241f}, {0.2311f, 0.2321f, 0.2331f, 0.2341f}}, {{0.2112f, 0.2122f, 0.2132f, 0.2142f}, {0.2212f, 0.2222f, 0.2232f, 0.2242f}, {0.2312f, 0.2322f, 0.2332f, 0.2342f}}} }); int row = 2; int col = 3; int z = 1; int fourth = 1; float expResult = 0.2342f; float result = instance.get(row, col, z, fourth); assertEquals(expResult, result, 0.0); }