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 2020/04/11 11:54:54 UTC

[commons-math] branch master updated (7b00584 -> 2764b82)

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-math.git.


    from 7b00584  Fixed "CheckStyle" warnings.
     new 2d8adbf  Avoid performance degradation of indexed access when using a linked list.
     new 2764b82  Update list of contributors.

The 2 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:
 pom.xml                                                            | 3 +++
 .../apache/commons/math4/distribution/EnumeratedDistribution.java  | 7 +++----
 2 files changed, 6 insertions(+), 4 deletions(-)


[commons-math] 02/02: Update list of contributors.

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-math.git

commit 2764b8239fe49a4328a0c51a74204a31ee1e451e
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Sat Apr 11 13:52:12 2020 +0200

    Update list of contributors.
---
 pom.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pom.xml b/pom.xml
index 08594e0..6347dc3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1069,6 +1069,9 @@
     <contributor>
       <name>Chris Popp</name>
     </contributor>
+    <contributor>
+      <name>Artavazd Balaian</name>
+    </contributor>
   </contributors>
 
 </project>


[commons-math] 01/02: Avoid performance degradation of indexed access when using a linked list.

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-math.git

commit 2d8adbf5148543bebc026d984f54cc43b9e9f545
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Sat Apr 11 13:42:03 2020 +0200

    Avoid performance degradation of indexed access when using a linked list.
    
    Thanks to Artavazd Balaian.
    
    Closes #134.
---
 .../apache/commons/math4/distribution/EnumeratedDistribution.java  | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java
index 5b1cd30..27f53bd 100644
--- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedDistribution.java
@@ -86,9 +86,8 @@ public class EnumeratedDistribution<T> implements Serializable {
                NotANumberException {
         singletons = new ArrayList<>(pmf.size());
         final double[] probs = new double[pmf.size()];
-
-        for (int i = 0; i < pmf.size(); i++) {
-            final Pair<T, Double> sample = pmf.get(i);
+        int count = 0;
+        for (Pair<T, Double> sample : pmf) {
             singletons.add(sample.getKey());
             final double p = sample.getValue();
             if (p < 0) {
@@ -100,7 +99,7 @@ public class EnumeratedDistribution<T> implements Serializable {
             if (Double.isNaN(p)) {
                 throw new NotANumberException();
             }
-            probs[i] = p;
+            probs[count++] = p;
         }
 
         probabilities = MathArrays.normalizeArray(probs, 1.0);