pallav12 / matrixMath-for-processing

Library specifically for processing to make Matrix operations easier
4 stars 1 forks source link

Matrix adjoint(float[][] array2) has hardcoded limit of input 4*4 matrix #4

Open KeesR opened 4 years ago

KeesR commented 4 years ago

Description

Matrix adjoint(float[][] array2) allocates its internal variable adjas float[4][4], which results in an ArrayIndexOutOfBoundsException when a matrix larger than 4x4 is used as input. A side effect is that the adjoint matrix as returned is also fixed to 4x4, even for smaller inputs, which is not not according to it definition. When adjoint matrix is used in inverse(), that is not a problem, as the superfluous elements are not used.

Solution

@@ -430,7 +430,7 @@ public class Matrix {
       throw new IllegalArgumentException("Input should Square Matrix");
     }
     int N = array2.length;
-    float[][] adj = new float[4][4];
+    float[][] adj = new float[N][N];
     if (N == 1) {
       adj[0][0] = 1;
       return new Matrix(adj);
KeesR commented 4 years ago

Discovered you have another repo with this library, here: https://github.com/pallav12/matrix-library-for-processing. And this specific issue is already solved there by dranorter.

Having these two different repo's on GitHub is somewhat confusing, since this one (https://github.com/pallav12/matrixMath-for-processing) is referenced from the Processing Libraries page.

Hope you pick up these items form here, and merge them in whatever repo is your current working version. If that is the other one, please also notify Processing.org to change the reference.