Why is lu decomposition faster
Active Oldest Votes. That made it clear! A beautifully written explanation can be found at gregorygundersen. Pankaj Pankaj 1 1 silver badge 4 4 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. Upcoming Events. Featured on Meta. Now live: A fully responsive profile. The unofficial elections nomination post.
But where does the difference come from? Or is my measurement method flawed? Thus I try to keep the amount of elements in the loop as low as possible. First, don't forget to also time the LU decomposition in a loop! Otherwise it's not really a fair comparison. If I do that, I get the following timings:. Since the matrix in this example is in fact symmetric, you'd also expect that Matlab will not do an LU decomposition. Replacing lu by chol gives a timing of You can see that L has a much more complicated sparsity pattern than U which is upper tridiagonal, corresponding to the sparsity pattern of A , so the corresponding substitution step will be much slower.
Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Why is the speed of the parts of the LU-decomposition so different? Ask Question. For each of these steps the CPU has to execute a loop, even if you didn't write one explicitly. Numpy abstracts these loops away but they still have to be executed! Of course oftentimes it can pay off to have X implicit fast loops in numpy instead of 1 python loop, but this is only the case for medium size arrays.
Also, a list comprehension really is only marginally faster than a regular for-loop. The scipy one is faster because it's a highly optimized implementation in a low level proramming language whereas python is a very high level language. In the end what this probably means is that you should appreciate your prof's code for its elegance and readability not for its speed :.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Why is my prof's version of LU decomposition faster than mine? Python numpy Ask Question. Asked 3 years, 9 months ago.
Active 3 years, 9 months ago. Viewed 2k times. L is a unit triangular matrix. NxN :type A: numpy.
0コメント