@Override
    public DenseMatrix matrixMultiply(Matrix other) {
        if (dim2 == other.getDimension1Size()) {
            if (other instanceof DenseMatrix) {
                DenseMatrix otherDense = (DenseMatrix) other;
                double[][] output = new double[dim1][otherDense.dim2];

                for (int i = 0; i < dim1; i++) {
                    for (int j = 0; j < otherDense.dim2; j++) {
                        output[i][j] = columnRowDot(i,j,otherDense);
                    }
                }

                return new DenseMatrix(output);
            } else if (other instanceof DenseSparseMatrix) {
                DenseSparseMatrix otherSparse = (DenseSparseMatrix) other;
                int otherDim2 = otherSparse.getDimension2Size();
                double[][] output = new double[dim1][otherDim2];

                for (int i = 0; i < dim1; i++) {
                    for (int j = 0; j < otherDim2; j++) {
                        output[i][j] = columnRowDot(i,j,otherSparse);
                    }
                }

                return new DenseMatrix(output);
            } else {
                throw new IllegalArgumentException("Unknown matrix type " + other.getClass().getName());
            }
        } else {
            throw new IllegalArgumentException("Invalid matrix dimensions, this.shape=" + Arrays.toString(shape) + ", other.shape = " + Arrays.toString(other.getShape()));
        }
    }
@Test
    public void matrixMatrixOtherTransposeTest() {
        //4x4 matrices
        DenseMatrix a = generateA();
        DenseMatrix b = generateB();
        DenseMatrix c = generateC();

        DenseMatrix aaT = generateAAT();
        assertEquals(aaT,a.matrixMultiply(a,false,true));
        DenseMatrix abT = generateABT();
        assertEquals(abT,a.matrixMultiply(b,false,true));
        DenseMatrix acT = generateACT();
        assertEquals(acT,a.matrixMultiply(c,false,true));

        DenseMatrix baT = generateBAT();
        assertEquals(baT,b.matrixMultiply(a,false,true));
        DenseMatrix bbT = generateBBT();
        assertEquals(bbT,b.matrixMultiply(b,false,true));
        DenseMatrix bcT = generateBCT();
        assertEquals(bcT,b.matrixMultiply(c,false,true));

        DenseMatrix caT = generateCAT();
        assertEquals(caT,c.matrixMultiply(a,false,true));
        DenseMatrix cbT = generateCBT();
        assertEquals(cbT,c.matrixMultiply(b,false,true));
        DenseMatrix ccT = generateCCT();
        assertEquals(ccT,c.matrixMultiply(c,false,true));
    }