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:18 UTC

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

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} */