1

I am trying to perform inversion on matrices larger than 10,000 x 10,000.

InverterTask<Double> matrixInverter = InverterTask.PRIMITIVE.make(storeM);
try{
       storeI = matrixInverter.invert(storeM);
 }catch (RecoverableCondition e){
       throw new RuntimeException(e);
 }

storeM is a matrix of size 10,000 x 10,000.

However, I ran into the following error :

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.ojalgo.array.Primitive64Array.<init>(Primitive64Array.java:368)
at org.ojalgo.matrix.store.PrimitiveDenseStore.<init>(PrimitiveDenseStore.java:482)
at org.ojalgo.matrix.store.PrimitiveDenseStore$1.makeZero(PrimitiveDenseStore.java:255)
at org.ojalgo.matrix.store.PrimitiveDenseStore$1.makeZero(PrimitiveDenseStore.java:95)
at org.ojalgo.matrix.decomposition.GenericDecomposition.makeZero(GenericDecomposition.java:105)
at org.ojalgo.matrix.decomposition.InPlaceDecomposition.setInPlace(InPlaceDecomposition.java:83)
at org.ojalgo.matrix.decomposition.LUDecomposition.compute(LUDecomposition.java:266)
at org.ojalgo.matrix.decomposition.LUDecomposition.decompose(LUDecomposition.java:94)
at org.ojalgo.matrix.decomposition.LUDecomposition.invert(LUDecomposition.java:199)
at distlearn.Inversion.main(Inversion.java:46)

What are the other methods that I can use in ojAlgo to perform such a task ?

Edit : I am actually looking to perform a kernel ridge regression using the dual of the problem. This means that for a dataset of N entries I may need to perform inversion of a NxN matrix.

YAMAZAKI1996
  • 35
  • 1
  • 10
  • You're going to need an enormous amount of memory to invert matrixes that big, no matter how you do it. What have you set your Java heap space to, and can you make it bigger? – Dawood ibn Kareem May 03 '19 at 05:34
  • It would help if you state what you plan to do with that inverse – do you really need to explicitly calculate the inverse? (Working with matrices that large you need to increase the heap regardless.) – apete May 03 '19 at 06:31
  • The matrix I would like to perform inverse on is actually symmetrical. Are there anyways to just perform inverse on the Upper/Lower triangular part of the matrix ? – YAMAZAKI1996 May 03 '19 at 07:32
  • When formulae include the inverse of some matrix (then multiplied by something) you almost never actually calculate that inverse. Instead you solve a corresponding equation system. In this case you should think about how to best solve that equation system, and then pick a suitable solver. Don't use the very high level InverterTask factories. – apete May 05 '19 at 08:48

1 Answers1

0

Depending on what you want to do with the result, there are other ways to your problem that doesn't involve inverting the matrix.

Assuming that you really need to invert it, you could do something as already answered on Mathematics Stack Exchange: Inversion of large matrices

It gives a solution to doing the inversion "in place" (it does allocate some temporary memory during the process, but it's said that it's much less than the normal inversion operation would need to be successful)

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
Álex Fogaça
  • 84
  • 1
  • 5