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 2019/10/23 13:41:22 UTC

[commons-numbers] branch master updated (e2e46b1 -> 2f5a658)

This is an automated email from the ASF dual-hosted git repository.

erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git.


    from e2e46b1  POM file standardization.
     new 91aacd8  Accessor.
     new 704e355  Javadoc.
     new 2f5a658  Fixed method "doubleValue()".

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/commons/numbers/field/FieldSquareMatrix.java   | 11 +++++++++--
 .../commons/numbers/field/FP64FieldSquareMatrixTest.java      |  6 ++++++
 .../java/org/apache/commons/numbers/fraction/BigFraction.java |  7 ++++---
 .../org/apache/commons/numbers/fraction/BigFractionTest.java  |  3 +++
 4 files changed, 22 insertions(+), 5 deletions(-)


[commons-numbers] 01/03: Accessor.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 91aacd8fad1612603b325c947733c74f65ba5516
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Wed Oct 23 13:05:02 2019 +0200

    Accessor.
---
 .../java/org/apache/commons/numbers/field/FieldSquareMatrix.java   | 7 +++++++
 .../apache/commons/numbers/field/FP64FieldSquareMatrixTest.java    | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java
index f8cc7ba..dc6b129 100644
--- a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java
+++ b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java
@@ -113,6 +113,13 @@ public class FieldSquareMatrix<T> {
     }
 
     /**
+     * @return the field associated with the matrix entries.
+     */
+    public Field<T> getField() {
+        return field;
+    }
+
+    /**
      * Sets all elements to the given value.
      *
      * @param value Value of the elements of the matrix.
diff --git a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64FieldSquareMatrixTest.java b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64FieldSquareMatrixTest.java
index d512e6f..9b4cc06 100644
--- a/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64FieldSquareMatrixTest.java
+++ b/commons-numbers-field/src/test/java/org/apache/commons/numbers/field/FP64FieldSquareMatrixTest.java
@@ -139,6 +139,12 @@ public class FP64FieldSquareMatrixTest {
                      0d);
     }
 
+    @Test
+    public void testGetField() {
+        final FieldSquareMatrix<FP64> a = FieldSquareMatrix.create(FP64Field.get(), 7);
+        Assertions.assertEquals(FP64Field.get(), a.getField());
+    }
+
     /**
      * Compares with result obtained from "Commons Math".
      *


[commons-numbers] 03/03: Fixed method "doubleValue()".

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 2f5a6581164cd5b4316a7998de654a197ee0e0f2
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Wed Oct 23 15:34:59 2019 +0200

    Fixed method "doubleValue()".
    
    Implementation still assumed that only the numerator can be negative.
    
    Closes #69. [Thanks to "bkrogh" for reporting failing use-cases.]
---
 .../main/java/org/apache/commons/numbers/fraction/BigFraction.java | 7 ++++---
 .../java/org/apache/commons/numbers/fraction/BigFractionTest.java  | 3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
index 4405d49..d73d720 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java
@@ -662,8 +662,9 @@ public class BigFraction
             return 0L;
         }
 
-        final long sign = numerator.signum() == -1 ? 1L : 0L;
+        final long sign = (numerator.signum() * denominator.signum()) == -1 ? 1L : 0L;
         final BigInteger positiveNumerator = numerator.abs();
+        final BigInteger positiveDenominator = denominator.abs();
 
         /*
          * The most significant 1-bit of a non-zero number is not explicitly
@@ -678,8 +679,8 @@ public class BigFraction
          * are not relevant for the significand of the prospective binary
          * floating-point value.
          */
-        final int denRightShift = denominator.getLowestSetBit();
-        final BigInteger divisor = denominator.shiftRight(denRightShift);
+        final int denRightShift = positiveDenominator.getLowestSetBit();
+        final BigInteger divisor = positiveDenominator.shiftRight(denRightShift);
 
         /*
          * Now, we're going to calculate the (significandLength + 2) most
diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
index 162d567..5d77884 100644
--- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
+++ b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionTest.java
@@ -183,6 +183,9 @@ public class BigFractionTest {
         Assertions.assertEquals(0d, BigFraction.ZERO.doubleValue(), 0d);
 
         assertDoubleValue(0.5, 1, 2);
+        assertDoubleValue(-0.5, -1, 2);
+        assertDoubleValue(-0.5, 1, -2);
+        assertDoubleValue(0.5, -1, -2);
         assertDoubleValue(1.0 / 3.0, 1, 3);
 
         //NUMBERS-120


[commons-numbers] 02/03: Javadoc.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 704e3557f1e1d45ee48bcf1f6e6a76e241c59a1c
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Wed Oct 23 13:10:06 2019 +0200

    Javadoc.
---
 .../main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java
index dc6b129..8f83088 100644
--- a/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java
+++ b/commons-numbers-field/src/main/java/org/apache/commons/numbers/field/FieldSquareMatrix.java
@@ -207,7 +207,7 @@ public class FieldSquareMatrix<T> {
     /**
      * Multiplication.
      *
-     * @param factor Matrix to multiply with.
+     * @param other Matrix to multiply with.
      * @return a new instance with the result of the multiplication.
      */
     public FieldSquareMatrix<T> multiply(FieldSquareMatrix<T> other) {
@@ -284,7 +284,7 @@ public class FieldSquareMatrix<T> {
     /**
      * Check that the given matrix has the same dimensions.
      *
-     * @param factor Matrix to check.
+     * @param other Matrix to check.
      * @throws IllegalArgumentException if the dimensions do not match.
      */
     private void checkDimension(FieldSquareMatrix<T> other) {