java.lang.NegativeArraySizeException

43 views
Skip to first unread message

Matías Roodschild

unread,
Mar 1, 2018, 3:43:52 PM3/1/18
to efficient-java-matrix-library-discuss
Hi There!

I'm using the EJML library and I have this error java.lang.NegativeArraySizeException

public class LargeMatrixMultTest {
    public static void main(String[] args) {
        Random rand = new Random();
        SimpleMatrix A = SimpleMatrix.random64(1, 202210, 0, 1, rand);
        SimpleMatrix B = SimpleMatrix.random64(1, 202210, 0, 1, rand);
       
        A.transpose().mult(B).get(0);
    }
}

Exception in thread "main" java.lang.NegativeArraySizeException
    at org.ejml.data.DMatrixRMaj.<init>(DMatrixRMaj.java:123)
    at org.ejml.simple.SimpleMatrix.<init>(SimpleMatrix.java:163)
    at org.ejml.simple.SimpleMatrix.createMatrix(SimpleMatrix.java:339)
    at org.ejml.simple.SimpleMatrix.createMatrix(SimpleMatrix.java:88)
    at org.ejml.simple.SimpleBase.mult(SimpleBase.java:157)

 I know that there is a big matrix.. but I really use a bigger one and I don't this problem (663 x 50000)

Thanks Peter!

Peter A

unread,
Mar 1, 2018, 6:59:23 PM3/1/18
to efficient-java-mat...@googlegroups.com
You're exceeding the maximum size of an array in Java by a good margin

2**31 - 202210*202210 = -3.8741e+10

Is the data really dense? There's support for sparse matrices which should be able to handle a matrix that large.


--
You received this message because you are subscribed to the Google Groups "efficient-java-matrix-library-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to efficient-java-matrix-library-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.

Matías Roodschild

unread,
Mar 1, 2018, 11:38:00 PM3/1/18
to efficient-java-matrix-library-discuss
Hi Peter,

Thanks for response and yes, you are right, it's a problem in my code, the real multiplication are A.mult(B.transpose())

Thanks Again!
Reply all
Reply to author
Forward
0 new messages