You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2016/04/22 03:39:36 UTC
[1/2] [math] Fixed failing unit test.
Repository: commons-math
Updated Branches:
refs/heads/develop baae2a6f3 -> f16d5b172
Fixed failing unit test.
Source of failure was MATH-1340: Expected exception is now wrapped in another exception.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/84143c46
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/84143c46
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/84143c46
Branch: refs/heads/develop
Commit: 84143c462986417ccfc5e8c05481e983cf668e2c
Parents: baae2a6
Author: Gilles <er...@apache.org>
Authored: Fri Apr 22 03:01:33 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri Apr 22 03:01:33 2016 +0200
----------------------------------------------------------------------
.../apache/commons/math4/random/JDKRandomAdaptorTest.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/84143c46/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java b/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java
index 5ba68c7..7360a88 100644
--- a/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java
+++ b/src/test/java/org/apache/commons/math4/random/JDKRandomAdaptorTest.java
@@ -80,9 +80,14 @@ public class JDKRandomAdaptorTest {
Assert.assertEquals(withoutReseed, withReseed, 0);
}
- @Test(expected=MathUnsupportedOperationException.class)
+ @Test
public void testSerializeIsNotSupported() {
- TestUtils.serializeAndRecover(new JDKRandomAdaptor(RandomSource.create(RandomSource.WELL_512_A)));
+ try {
+ TestUtils.serializeAndRecover(new JDKRandomAdaptor(RandomSource.create(RandomSource.WELL_512_A)));
+ } catch (Exception e) {
+ Throwable cause = e.getCause();
+ Assert.assertTrue(cause instanceof MathUnsupportedOperationException);
+ }
}
/**
[2/2] [math] Fixed failing tests.
Posted by er...@apache.org.
Fixed failing tests.
Source of failure was MATH-1355: "EigenDecomposition" was assuming that a diagonal matrix could be made non-diagonal.
Added a utility method that creates a dense matrix from an array specifying its diagonal elements.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/f16d5b17
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/f16d5b17
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/f16d5b17
Branch: refs/heads/develop
Commit: f16d5b1722eb55c2d55eb623999f16799b088b98
Parents: 84143c4
Author: Gilles <er...@apache.org>
Authored: Fri Apr 22 03:33:53 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Fri Apr 22 03:33:53 2016 +0200
----------------------------------------------------------------------
.../commons/math4/linear/EigenDecomposition.java | 2 +-
.../apache/commons/math4/linear/MatrixUtils.java | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/f16d5b17/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java b/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
index aa92b5e..f9afeb7 100644
--- a/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
+++ b/src/main/java/org/apache/commons/math4/linear/EigenDecomposition.java
@@ -189,7 +189,7 @@ public class EigenDecomposition {
if (cachedD == null) {
// cache the matrix for subsequent calls
- cachedD = MatrixUtils.createRealDiagonalMatrix(realEigenvalues);
+ cachedD = MatrixUtils.createRealMatrixWithDiagonal(realEigenvalues);
for (int i = 0; i < imagEigenvalues.length; i++) {
if (Precision.compareTo(imagEigenvalues[i], 0.0, EPSILON) > 0) {
http://git-wip-us.apache.org/repos/asf/commons-math/blob/f16d5b17/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
index 86d74d6..7b41561 100644
--- a/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
+++ b/src/main/java/org/apache/commons/math4/linear/MatrixUtils.java
@@ -210,6 +210,7 @@ public class MatrixUtils {
* The array elements will be copied.
* @return a diagonal matrix instance.
*
+ * @see #createRealMatrixWithDiagonal(double[])
* @since 2.0
*/
public static DiagonalMatrix createRealDiagonalMatrix(final double[] diagonal) {
@@ -217,6 +218,24 @@ public class MatrixUtils {
}
/**
+ * Creates a dense matrix with the specified diagonal elements.
+ *
+ * @param diagonal Diagonal elements of the matrix.
+ * @return a matrix instance.
+ *
+ * @see #createRealDiagonalMatrix(double[])
+ * @since 4.0
+ */
+ public static RealMatrix createRealMatrixWithDiagonal(final double[] diagonal) {
+ final int size = diagonal.length;
+ final RealMatrix m = createRealMatrix(size, size);
+ for (int i = 0; i < size; i++) {
+ m.setEntry(i, i, diagonal[i]);
+ }
+ return m;
+ }
+
+ /**
* Returns a diagonal matrix with specified elements.
*
* @param <T> the type of the field elements