Matrix { public Matrix multiply(Matrix by){ Matrix rslt = new Matrix(); float[] a = vals; float[] b = by.vals; float[] c = rslt.vals; c[I11] = a[I11]*b[I11] + a[I12]*b[I21] + a[I13]*b[I31]; c[I12] = a[I11]*b[I12] + a[I12]*b[I22] + a[I13]*b[I32]; c[I13] = a[I11]*b[I13] + a[I12]*b[I23] + a[I13]*b[I33]; c[I21] = a[I21]*b[I11] + a[I22]*b[I21] + a[I23]*b[I31]; c[I22] = a[I21]*b[I12] + a[I22]*b[I22] + a[I23]*b[I32]; c[I23] = a[I21]*b[I13] + a[I22]*b[I23] + a[I23]*b[I33]; c[I31] = a[I31]*b[I11] + a[I32]*b[I21] + a[I33]*b[I31]; c[I32] = a[I31]*b[I12] + a[I32]*b[I22] + a[I33]*b[I32]; c[I33] = a[I31]*b[I13] + a[I32]*b[I23] + a[I33]*b[I33]; return rslt; } Matrix();  Matrix(float tx, float ty);  Matrix(float a, float b, float c, float d, float e, float f); float get(int index); Matrix multiply(Matrix by); Matrix subtract(Matrix arg); float getDeterminant(); boolean equals(Object obj); int hashCode(); 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 testMultiply() throws Exception{ Matrix m1 = new Matrix(2, 3, 4, 5, 6, 7); Matrix m2 = new Matrix(8, 9, 10, 11, 12, 13); Matrix shouldBe = new Matrix(46, 51, 82, 91, 130, 144); Matrix rslt = m1.multiply(m2); Assert.assertEquals(shouldBe, rslt); }