Вопрос

I'm working in a project that need to get SVD (Single Values Decomposition) for a matrix of 74000 X 640 dimension. I tried those three libraries: Jama, efficient Java Matrix library (EJML), and OjAlgo.I choose these three based on the Java Matrix benchmark memory result in SVD. At first I used Jama but I discovered then that the number of rows must be >= the number of column and I will need to get SVD for any matrix dimensions in another step. So, I moved to EJML and OjAlgo but I have some Question/problem with EJML:

EJML--> it give the right results for SVD but when I enlarged the matrix size to 74000 X 640 dimension it give me heap memory exception, so is there a restriction on the matrix size for the library ??

here is the code I used for creating the Matrix:

 SimpleMatrix A = new SimpleMatrix(74000, 640);

please help me to understand and fix my problem.

Thank you

Это было полезно?

Решение

What is the size of your JVM heap? Assuming double precision numbers, densely packed, your matrix of 74000 X 640 will take ~ 361Mb of RAM. I imagine the working memory for calculating the SVD is at least this again. So it could well be that there is no memory limit in the library, but just that you are using a lot of it and the JVM does not have enough heap space to run your calculations.

Другие советы

Sorry, I fix my problem with OjAlgo by adding one line of code (function compute) the code now look like:

MatrixFactory<?> tmpFactory = PrimitiveMatrix.FACTORY;
double[][] tmpData = new double[][] {{1,2,3,4,5},{11,12,18,19,25},{89,75,14,21,26},{33,24,47,15,49}};
BasicMatrix tmpH = tmpFactory.rows(tmpData);
Access2D<Double> j = (Access2D<Double>)tmpH;
SingularValue f = SingularValueDecomposition.make(j);
f.compute(j);

Thanks..

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top