Timeline for How to speed up my code using Sparse-array possibly?
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 23, 2020 at 0:36 | history | edited | Delaram Nematollahi | CC BY-SA 4.0 |
added 1406 characters in body
|
Mar 17, 2020 at 17:40 | vote | accept | Delaram Nematollahi | ||
Mar 17, 2020 at 15:00 | history | tweeted | twitter.com/StackMma/status/1239929611460509698 | ||
Mar 17, 2020 at 7:42 | answer | added | Henrik Schumacher | timeline score: 5 | |
Mar 17, 2020 at 6:59 | comment | added | Henrik Schumacher | Another issue (related to that) is that the final matrix seems to be a diagonal matrix. So there is also no need to compute the off-diagonal entries. | |
Mar 17, 2020 at 6:59 | comment | added | Henrik Schumacher |
Yes, it is certainly possible to speed this up considerably. Basically 99.9 percent of the numbers in the Table you Total over are zeroes. There should be a simple logic to figure out whether the entries have to be computed in the first place. To point out what I mean: constructions like Sum[f[i] g[j] KroneckerDelta[i, j], {i, 1, n}, {j, 1, n}] are popular with physicists as they allow simple paper calculation, but super inefficient on a compute because they require $\Theta(n^2)$. Instead, Sum[f[i] g[i], {i, 1, n}] leads to the same result in $\Theta(n)$.
|
|
Mar 17, 2020 at 1:36 | history | edited | MikeY | CC BY-SA 4.0 |
deleted 322 characters in body
|
Mar 17, 2020 at 0:16 | history | asked | Delaram Nematollahi | CC BY-SA 4.0 |