corradin / Eigenvalue

Calculate the eigenvalue and eigenvector of a matrix
1 stars 0 forks source link

memory issues #1

Open Fil opened 6 years ago

Fil commented 6 years ago

Hello, thanks a lot for this wrapper 👏

I'm loading it in @observablehq with https://bundle.run/matrix-eig, see https://beta.observablehq.com/@fil/hello-matrix-eig

I noticed that if you request too much memory once (with a large matrix, N=500 in my example), then there is no way to scale back, the page is as good as dead and one must reload to clear the error.

abort("Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 16777216, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 ") at Error
    at jsStackTrace (https://bundle.run/matrix-eig@1.0.0:117:17947)

(Given the error message I'm not sure there is a way around this.)

corradin commented 6 years ago

Hi Philippe, thx I appreciate your feedback. I'll look into it. have you tried running your big matrix through Matlab's eig function? I'm curious how it behaves there.

Fil commented 6 years ago

No, I don’t use matlab :)

I'm currently trying to understand spectral graph theory, so playing a bit with examples.

Le mar. 7 août 2018 à 16:56, Riccardo Corradin notifications@github.com a écrit :

Hi Philippe, thx I appreciate your feedback. I'll look into it. have you tried running your big matrix through Matlab's eig function? I'm curious how it behaves there.

Fil commented 6 years ago

For spectral embedding, I just need the n first eigenvectors of my matrix, so I guess I should try dsyevr, or even ssyevr.

Interestingly, https://github.com/mljs/matrix native js approach to decomposition works well for matrices under 500x500 — but it doesn't seem to scale, with measured times in O(n^2) or worse.

corradin commented 6 years ago

Yes I guess so. Basically, you can add these functions to the library. Lapack has a lot of them. Maybe do something like decomposition and wrap it into await async so you avoid freezing your app?

corradin commented 6 years ago

Hi Fil, In order to solve this issue I need to rebuild emlapack. I will also add some error handling. I'm not aware of any eig decomposition methods for large matrices. I did some research on the internet, but no solution found and I'm not a mathematician. Will keep you posted.