Matrix implements Serializable { public Matrix subtract(Matrix arg){ Matrix rslt = new Matrix(); float[] a = vals; float[] b = arg.vals; float[] c = rslt.vals; c[I11] = a[I11]-b[I11]; c[I12] = a[I12]-b[I12]; c[I13] = a[I13]-b[I13]; c[I21] = a[I21]-b[I21]; c[I22] = a[I22]-b[I22]; c[I23] = a[I23]-b[I23]; c[I31] = a[I31]-b[I31]; c[I32] = a[I32]-b[I32]; c[I33] = a[I33]-b[I33]; return rslt; } Matrix();  Matrix(float tx, float ty);  Matrix(float e11, float e12, float e13, float e21, float e22, float e23, float e31, float e32, float e33);  Matrix(float a, float b, float c, float d, float e, float f); float get(int index); Matrix multiply(Matrix by); Matrix add(Matrix arg); Matrix subtract(Matrix arg); float getDeterminant(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final int I11; static final int I12; static final int I13; static final int I21; static final int I22; static final int I23; static final int I31; static final int I32; static final int I33; }
@Test public void testSubtract() { Matrix m1 = new Matrix(1, 2, 3, 4, 5, 6); Matrix m2 = new Matrix(6, 5, 4, 3, 2, 1); Matrix shouldBe = new Matrix(-5, -3,0, -1, 1,0, 3, 5,0); Matrix rslt = m1.subtract(m2); Assert.assertEquals(shouldBe, rslt); }