Skip to content

Can't use toBinary method on large matrices #282

@HowardLander

Description

@HowardLander

The following code fails test class fails on a fairly small (but not sparse) matrix:

Here's the invocation:

/usr/java/jdk1.7.0_51/bin/java -Xmx8000m -cp .:./la4j-0.6.0.jar MatrixTestBug
java.lang.IllegalArgumentException
at java.nio.ByteBuffer.allocate(ByteBuffer.java:330)
at org.la4j.matrix.sparse.CRSMatrix.toBinary(CRSMatrix.java:1007)
at MatrixTestBug.main(MatrixTestBug.java:13)

and here's the code (MatrixTestBug.java)

import java.io.;
import org.la4j.
;

public class MatrixTestBug {

public static void main(String[] args) {

 org.la4j.matrix.sparse.CRSMatrix theMatrix = new            org.la4j.matrix.sparse.CRSMatrix(15000,15000);
   theMatrix.setAll(.5);

   try {
       FileOutputStream fos = new FileOutputStream("test.tmp");
       byte [] theMatrixBytes = theMatrix.toBinary();
   } catch (Exception e) {
       e.printStackTrace();
   }
}

}

One possible work around (at least for me) for this would be to restore the writeExternal and readExternal methods to the matrix classes. I suspect I could also ignore this problem if the matrix classes were serializable, as the only reason I am doing this is to write the matrix (and some other data) to a file. Any ideas?

Thanks
Howard

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions