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 2023/03/06 02:04:17 UTC

[commons-math] branch master updated (889d27b5d -> 62b90523c)

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 889d27b5d codecov-commenter => notifications
     new 5f76f8384 MATH-1654: optimize Array2DRowRealMatrix getEntry
     new 6c493a4f2 MATH-1589: Remove spurious "throws" clause.
     new 9321062e1 Update description for next release.
     new 62b90523c Track changes.

The 4 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:
 .../math4/legacy/linear/Array2DRowRealMatrix.java  | 85 ++++++++--------------
 src/changes/changes.xml                            | 48 +++++++++++-
 2 files changed, 79 insertions(+), 54 deletions(-)


[commons-math] 01/04: MATH-1654: optimize Array2DRowRealMatrix getEntry

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 5f76f8384d8bb8b933ff1474109e74fc067d3b84
Author: Cyril de Catheu <cd...@hey.com>
AuthorDate: Sat Mar 4 23:58:20 2023 +0100

    MATH-1654: optimize Array2DRowRealMatrix getEntry
---
 .../commons/math4/legacy/linear/Array2DRowRealMatrix.java      | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java
index e690201b1..bd01de8cc 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java
@@ -299,8 +299,14 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     @Override
     public double getEntry(final int row, final int column)
         throws OutOfRangeException {
-        MatrixUtils.checkMatrixIndex(this, row, column);
-        return data[row][column];
+        try {
+            return data[row][column];
+        } catch (IndexOutOfBoundsException e) {
+            // throw the exact cause of the exception
+            MatrixUtils.checkMatrixIndex(this, row, column);
+            // should never happen
+            throw e;
+        }
     }
 
     /** {@inheritDoc} */


[commons-math] 03/04: Update description for next release.

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 9321062e12264f269bc205849765184285612fe3
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Mon Mar 6 02:42:23 2023 +0100

    Update description for next release.
---
 src/changes/changes.xml | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f7f60ca7b..ce3013736 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -52,7 +52,50 @@ If the output is not quite correct, check for invisible trailing spaces!
     <title>Apache Commons Math Release Notes</title>
   </properties>
   <body>
-    <release version="TBD" date="TBD" description="TBD">
+    <!-- <release version="TBD" date="TBD" description="TBD">
+    </release> -->
+
+    <release version="4.0-beta2" date="TBD" description="
+This is a major release that requires source changes in applications.
+
+Lower-level functionality has been split off to new components, often
+ with bug-fixes, performance enhancements and improved API:
+  Commons RNG,
+  Commons Numbers,
+  Commons Geometry,
+  Commons Statistics.
+
+Functionality still within Commons Math has been modularized and
+ partly refactored.
+ This is a work-in-progress (help welcome).
+ Codes for which the refactoring has not been undertaken (or was
+ deemed incomplete) have been moved to 'legacy' modules.
+
+The minimum version of the Java platform required to compile and use
+ Commons Math is Java 8.
+
+Users are encouraged to upgrade to this version, and to the new
+ components listed above (they are now Commons Math's dependencies).
+
+For code now located in the 'commons-math-legacy' module, upgrading
+ will be a matter of changing the top-level package name:
+ From 'org.apache.commons.math3' to 'org.apache.commons.math4.legacy'.
+ Code in the 'commons-math-legacy-core' module comprise classes that
+ moved from package 'org.apache.commons.math3' and package
+ 'org.apache.commons.math3.util' (e.g. 'MathArrays') to package
+ 'org.apache.commons.math4.legacy.core'.
+
+Notes:
+ Class 'FastMath' was renamed 'AccurateMath' (now located in package
+ 'org.apache.commons.math4.legacy.core.jdkmath').
+
+Caveat:
+ Although hundreds of issues have been fixed (see 'git log' and the
+ reports in the bug-tracking system of all the listed components),
+ many remain due to the lack of human resources necessary in order
+ to support the whole codebase (it was one of the main reasons for
+ creating more focused components).
+">
     </release>
 
     <release version="4.0-beta1" date="2022-12-20" description="


[commons-math] 02/04: MATH-1589: Remove spurious "throws" clause.

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 6c493a4f20e5ac3bd04d35c1042154e3e9da6392
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Mon Mar 6 02:30:45 2023 +0100

    MATH-1589: Remove spurious "throws" clause.
---
 .../math4/legacy/linear/Array2DRowRealMatrix.java  | 75 +++++++---------------
 1 file changed, 24 insertions(+), 51 deletions(-)

diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java
index bd01de8cc..69992adad 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrix.java
@@ -22,10 +22,7 @@ import java.io.Serializable;
 import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
 import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
 import org.apache.commons.math4.legacy.exception.NoDataException;
-import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.legacy.exception.NullArgumentException;
-import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.exception.OutOfRangeException;
 import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
 
 /**
@@ -49,12 +46,11 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
      *
      * @param rowDimension Number of rows in the new matrix.
      * @param columnDimension Number of columns in the new matrix.
-     * @throws NotStrictlyPositiveException if the row or column dimension is
-     * not positive.
+     * @throws org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException
+     * if the row or column dimension is not positive.
      */
     public Array2DRowRealMatrix(final int rowDimension,
-                                final int columnDimension)
-        throws NotStrictlyPositiveException {
+                                final int columnDimension) {
         super(rowDimension, columnDimension);
         data = new double[rowDimension][columnDimension];
     }
@@ -72,8 +68,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
      * @throws NullArgumentException if {@code d} is {@code null}.
      * @see #Array2DRowRealMatrix(double[][], boolean)
      */
-    public Array2DRowRealMatrix(final double[][] d)
-        throws DimensionMismatchException, NoDataException, NullArgumentException {
+    public Array2DRowRealMatrix(final double[][] d) {
         copyIn(d);
     }
 
@@ -93,9 +88,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
      * @throws NullArgumentException if {@code d} is {@code null}.
      * @see #Array2DRowRealMatrix(double[][])
      */
-    public Array2DRowRealMatrix(final double[][] d, final boolean copyArray)
-        throws DimensionMismatchException, NoDataException,
-        NullArgumentException {
+    public Array2DRowRealMatrix(final double[][] d, final boolean copyArray) {
         if (copyArray) {
             copyIn(d);
         } else {
@@ -137,8 +130,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     /** {@inheritDoc} */
     @Override
     public RealMatrix createMatrix(final int rowDimension,
-                                   final int columnDimension)
-        throws NotStrictlyPositiveException {
+                                   final int columnDimension) {
         return new Array2DRowRealMatrix(rowDimension, columnDimension);
     }
 
@@ -156,8 +148,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
      * @throws MatrixDimensionMismatchException if {@code m} is not the same
      * size as {@code this}.
      */
-    public Array2DRowRealMatrix add(final Array2DRowRealMatrix m)
-        throws MatrixDimensionMismatchException {
+    public Array2DRowRealMatrix add(final Array2DRowRealMatrix m) {
         // Safety check.
         checkAdd(m);
 
@@ -184,8 +175,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
      * @throws MatrixDimensionMismatchException if {@code m} is not the same
      * size as {@code this}.
      */
-    public Array2DRowRealMatrix subtract(final Array2DRowRealMatrix m)
-        throws MatrixDimensionMismatchException {
+    public Array2DRowRealMatrix subtract(final Array2DRowRealMatrix m) {
         checkAdd(m);
 
         final int rowCount    = getRowDimension();
@@ -211,8 +201,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
      * @throws DimensionMismatchException if
      * {@code columnDimension(this) != rowDimension(m)}
      */
-    public Array2DRowRealMatrix multiply(final Array2DRowRealMatrix m)
-        throws DimensionMismatchException {
+    public Array2DRowRealMatrix multiply(final Array2DRowRealMatrix m) {
         checkMultiply(m);
 
         final int nRows = this.getRowDimension();
@@ -263,9 +252,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     /** {@inheritDoc} */
     @Override
     public void setSubMatrix(final double[][] subMatrix, final int row,
-                             final int column)
-        throws NoDataException, OutOfRangeException,
-        DimensionMismatchException, NullArgumentException {
+                             final int column) {
         if (data == null) {
             if (row > 0) {
                 throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
@@ -297,8 +284,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
 
     /** {@inheritDoc} */
     @Override
-    public double getEntry(final int row, final int column)
-        throws OutOfRangeException {
+    public double getEntry(final int row, final int column) {
         try {
             return data[row][column];
         } catch (IndexOutOfBoundsException e) {
@@ -311,8 +297,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
 
     /** {@inheritDoc} */
     @Override
-    public void setEntry(final int row, final int column, final double value)
-        throws OutOfRangeException {
+    public void setEntry(final int row, final int column, final double value) {
         MatrixUtils.checkMatrixIndex(this, row, column);
         data[row][column] = value;
     }
@@ -320,8 +305,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     /** {@inheritDoc} */
     @Override
     public void addToEntry(final int row, final int column,
-                           final double increment)
-        throws OutOfRangeException {
+                           final double increment) {
         MatrixUtils.checkMatrixIndex(this, row, column);
         data[row][column] += increment;
     }
@@ -329,8 +313,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     /** {@inheritDoc} */
     @Override
     public void multiplyEntry(final int row, final int column,
-                              final double factor)
-        throws OutOfRangeException {
+                              final double factor) {
         MatrixUtils.checkMatrixIndex(this, row, column);
         data[row][column] *= factor;
     }
@@ -349,8 +332,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
 
     /** {@inheritDoc} */
     @Override
-    public double[] operate(final double[] v)
-        throws DimensionMismatchException {
+    public double[] operate(final double[] v) {
         final int nRows = this.getRowDimension();
         final int nCols = this.getColumnDimension();
         if (v.length != nCols) {
@@ -370,8 +352,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
 
     /** {@inheritDoc} */
     @Override
-    public double[] preMultiply(final double[] v)
-        throws DimensionMismatchException {
+    public double[] preMultiply(final double[] v) {
         final int nRows = getRowDimension();
         final int nCols = getColumnDimension();
         if (v.length != nRows) {
@@ -393,8 +374,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     /** {@inheritDoc} */
     @Override
     public RealMatrix getSubMatrix(final int startRow, final int endRow,
-                                   final int startColumn, final int endColumn)
-            throws OutOfRangeException, NumberIsTooSmallException {
+                                   final int startColumn, final int endColumn) {
         MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
         final int rowCount = endRow - startRow + 1;
         final int columnCount = endColumn - startColumn + 1;
@@ -442,8 +422,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     @Override
     public double walkInRowOrder(final RealMatrixChangingVisitor visitor,
                                  final int startRow, final int endRow,
-                                 final int startColumn, final int endColumn)
-        throws OutOfRangeException, NumberIsTooSmallException {
+                                 final int startColumn, final int endColumn) {
         MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
         visitor.start(getRowDimension(), getColumnDimension(),
                       startRow, endRow, startColumn, endColumn);
@@ -460,8 +439,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     @Override
     public double walkInRowOrder(final RealMatrixPreservingVisitor visitor,
                                  final int startRow, final int endRow,
-                                 final int startColumn, final int endColumn)
-        throws OutOfRangeException, NumberIsTooSmallException {
+                                 final int startColumn, final int endColumn) {
         MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
         visitor.start(getRowDimension(), getColumnDimension(),
                       startRow, endRow, startColumn, endColumn);
@@ -507,8 +485,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     @Override
     public double walkInColumnOrder(final RealMatrixChangingVisitor visitor,
                                     final int startRow, final int endRow,
-                                    final int startColumn, final int endColumn)
-        throws OutOfRangeException, NumberIsTooSmallException {
+                                    final int startColumn, final int endColumn) {
         MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
         visitor.start(getRowDimension(), getColumnDimension(),
                       startRow, endRow, startColumn, endColumn);
@@ -525,8 +502,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     @Override
     public double walkInColumnOrder(final RealMatrixPreservingVisitor visitor,
                                     final int startRow, final int endRow,
-                                    final int startColumn, final int endColumn)
-        throws OutOfRangeException, NumberIsTooSmallException {
+                                    final int startColumn, final int endColumn) {
         MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
         visitor.start(getRowDimension(), getColumnDimension(),
                       startRow, endRow, startColumn, endColumn);
@@ -561,15 +537,13 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
      * @throws DimensionMismatchException if the input array is not rectangular.
      * @throws NullArgumentException if the input array is {@code null}.
      */
-    private void copyIn(final double[][] in)
-        throws DimensionMismatchException, NoDataException, NullArgumentException {
+    private void copyIn(final double[][] in) {
         setSubMatrix(in, 0, 0);
     }
 
     /** {@inheritDoc} */
     @Override
-    public double[] getRow(final int row)
-        throws OutOfRangeException {
+    public double[] getRow(final int row) {
         MatrixUtils.checkRowIndex(this, row);
         final int nCols = getColumnDimension();
         final double[] out = new double[nCols];
@@ -580,8 +554,7 @@ public class Array2DRowRealMatrix extends AbstractRealMatrix implements Serializ
     /** {@inheritDoc} */
     @Override
     public void setRow(final int row,
-                       final double[] array)
-        throws OutOfRangeException, MatrixDimensionMismatchException {
+                       final double[] array) {
         MatrixUtils.checkRowIndex(this, row);
         final int nCols = getColumnDimension();
         if (array.length != nCols) {


[commons-math] 04/04: Track changes.

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 62b90523c52bc958d9afee99dc7d57e328f7302c
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Mon Mar 6 02:43:05 2023 +0100

    Track changes.
    
    Closes #230.
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ce3013736..54a6a0d00 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -96,6 +96,9 @@ Caveat:
  to support the whole codebase (it was one of the main reasons for
  creating more focused components).
 ">
+      <action dev="erans" type="update" issue="MATH-1654" due-to="Cyril de Catheu">
+        "Array2DRowRealMatrix": Performance enhancement ("getEntry").
+      </action>
     </release>
 
     <release version="4.0-beta1" date="2022-12-20" description="