diff --git a/src/main/java/org/apache/commons/math3/linear/DiagonalMatrix.java b/src/main/java/org/apache/commons/math3/linear/DiagonalMatrix.java index 237fa2665..b8dccbb2f 100644 --- a/src/main/java/org/apache/commons/math3/linear/DiagonalMatrix.java +++ b/src/main/java/org/apache/commons/math3/linear/DiagonalMatrix.java @@ -103,7 +103,7 @@ public class DiagonalMatrix extends AbstractRealMatrix /** {@inheritDoc} */ @Override - public DiagonalMatrix copy() { + public RealMatrix copy() { return new DiagonalMatrix(data); } diff --git a/src/test/java/org/apache/commons/math3/linear/DiagonalMatrixTest.java b/src/test/java/org/apache/commons/math3/linear/DiagonalMatrixTest.java index 097b5d3f8..3379dbf5e 100644 --- a/src/test/java/org/apache/commons/math3/linear/DiagonalMatrixTest.java +++ b/src/test/java/org/apache/commons/math3/linear/DiagonalMatrixTest.java @@ -97,7 +97,7 @@ public class DiagonalMatrixTest { public void testCopy() { final double[] d = { -1.2, 3.4, 5 }; final DiagonalMatrix m = new DiagonalMatrix(d, false); - final DiagonalMatrix p = m.copy(); + final DiagonalMatrix p = (DiagonalMatrix) m.copy(); for (int i = 0; i < m.getRowDimension(); ++i) { Assert.assertEquals(m.getEntry(i, i), p.getEntry(i, i), 1.0e-20); }