### Question:
Matrix { public Matrix power(int k) { if (height != width) { throw new IllegalArgumentException("Matrix is not a square"); } if (k < 1) { throw new IllegalArgumentException("Invalid power"); } if (k == 1) { return this; } Matrix matrix = this; for (int i = 1; i < k; i++) { matrix = multiply(matrix); } return matrix; } Matrix(int height, int width, double[] data);  Matrix(int height, int width);  Matrix(int height, int width, double value); boolean equals(Matrix matrix); Matrix multiplyWithTime(Matrix matrix); Matrix multiply(Matrix matrix); Matrix multiplyNativeWithTime(Matrix matrix); Matrix multiplyNative(Matrix matrix); Matrix powerWithTime(int k); Matrix power(int k); Matrix powerNativeWithTime(int k); Matrix powerNative(int k);  }### Answer:
@Test public void testPower() { Matrix matrix1 = new Matrix(2, 2, new double[]{1, 2, 3, 4}); Matrix matrix2 = matrix1.powerNative(1); Assert.assertTrue(matrix1.equals(matrix2)); Matrix matrix3 = new Matrix(2, 2, new double[]{7, 10, 15, 22}); Matrix matrix4 = matrix1.power(2); Assert.assertTrue(matrix3.equals(matrix4)); Matrix matrix5 = new Matrix(2, 2, new double[]{37, 54, 81, 118}); Matrix matrix6 = matrix1.power(3); Assert.assertTrue(matrix5.equals(matrix6)); Matrix matrix7 = matrix1.powerNative(1); Assert.assertTrue(matrix1.equals(matrix7)); Matrix matrix8 = new Matrix(2, 2, new double[]{7, 10, 15, 22}); Matrix matrix9 = matrix1.powerNative(2); Assert.assertTrue(matrix8.equals(matrix9)); Matrix matrix10 = new Matrix(2, 2, new double[]{37, 54, 81, 118}); Matrix matrix11 = matrix1.powerNative(3); Assert.assertTrue(matrix10.equals(matrix11)); }