public boolean eq(Matrix3D B) {
        Matrix3D A = this;
        if (B.M != A.M || B.N != A.N || B.K != A.K) throw new RuntimeException("Illegal matrix dimensions.");
        for (int i = 0; i < M; i++)
            for (int j = 0; j < N; j++)
            	for (int l = 0; l < K; l++)
            		if (A.data[i][j][l] != B.data[i][j][l]) return false;
        return true;
    }