-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matrices in the objective function #1
Comments
For some reason matlab's kronSparse seems not to take into account the fact that the matrix will be sparse when computing the memory footprint of the resulting matrix. One option would be to rewrite the kronSparse function or a specialized function to compute
however in your case it seems that simply adding parenteses to change the multiplication evaluation ordering solves the problem.
or with a fix from the last commit you can avoid creating the matrix
The second line is faster to evaluate |
Thank you so much! It is now very fast and does not return a memory error. Can't wait to try it in a Newton iteration for solving nonlinear elasticity PDEs. |
Hi, I'm running into a similar memory error while trying to solve a system of PDEs. The problem comes from the multiplication of NxN sparse matrices of the form: The call to spdiags() seems to be the issue. I replaced it with multiplications as you did above, but the performance is much worse. Any suggestions? Aside from the memory error with large simulations, I'm seeing good autodiff performance. |
@d-cogswell , it would be great if you could provide me with some matrices A,B and vector v to replicate the problem. Did you try A*(v.*B)? |
@martinResearch sure, here's an example. I tried the alternate multiplication you suggested but it's really slow. Is it performing a dense multiply?
|
Using a different ordering of the multiplications, it runs fast for me:
it runs in 0.16 sec on my machine for N=20000. |
Thanks for the tip! The order of operations really makes a big difference. |
The following code:
does not work. Error message is:
It would be really good if this tool worked with objective functions which include manipulations with large sparse matrices.
The text was updated successfully, but these errors were encountered: