Tensor extends BaseTensor { public void reshape(int... shape) { if( this.shape.length != shape.length ) { this.shape = new int[shape.length]; } System.arraycopy(shape,0,this.shape,0,shape.length); reshape(); }  abstract double getDouble( int ...coordinate ); abstract Object getData(); abstract void setData( Object data ); void reshape(int... shape); void reshape( int length0 ); void reshape( int length1 , int length0); void reshape( int length2 , int length1 , int length0 ); void reshape( int length3 , int length2 , int length1 , int length0 ); void reshape( int length4 , int length3 , int length2 , int length1 , int length0 ); void reshape(); int idx(int ...coordinate ); int idx(int axis0 ); int idx(int axis1, int axis0 ); int idx(int axis2, int axis1 , int axis0 ); int idx(int axis3, int axis2 , int axis1 , int axis0 ); int idx(int axis4, int axis3 , int axis2 , int axis1 , int axis0 ); void computeStrides(); int stride( int index ); void copyShape( int shape[] ); int length(int dimension ); int length(); abstract T create( int ...shape ); T createLike(); int[] createCoor(); int[] indexToCoor( int index , int []storage ); void setTo( T original ); abstract void zero(); T copy(); boolean isSub(); T subtensor(int startIndex, int[] shape); public int startIndex; public boolean subtensor; public int strides; }
@Test public void isShape() { Dummy tensor = new Dummy(); tensor.reshape(10,5,6,7); int[] shape = new int[]{10,5,6,7}; assertTrue(tensor.isShape(10,5,6,7)); for (int i = 0; i < shape.length; i++) { int before = shape[i]; shape[i] = before+1; assertFalse(tensor.isShape(shape)); shape[i] = before; } Dummy foo = new Dummy(); foo.reshape(10,5,6,7); assertTrue(tensor.isShape(foo.getShape())); }