Farbfetzen / fractalplotr

Make beautiful fractals with R
Other
0 stars 0 forks source link

Accelerate sandpile creation #14

Closed Farbfetzen closed 4 years ago

Farbfetzen commented 5 years ago

Reduce the time it takes to generate big sandpiles. Use the symmetry.

Farbfetzen commented 5 years ago

Drop 1 million grains in the middle and wait for an eternity for it to finish. Looks like the time it takes grows quadratically. Therefore using symmetry and only iterating over a quarter of the matrix may help.

Farbfetzen commented 5 years ago

Ok, I implemented the improvement of iterating over the top right quarter of the matrix. The function is now much faster. But is still takes very long for a million grains. Maybe I'm missing something and have to think of a better way. I could iterate over only an eight of the matrix. And also better handle the edges.

Farbfetzen commented 4 years ago

New idea: Instead of only distributing 4 grains to neighbouring cells, maybe divide the stack into quarters and move those around. But first add a regression test for large sandpiles. See comment in sandpile test file. Measure the performance before and after.

Farbfetzen commented 4 years ago

Maybe it would be good to instead of using indices just copy parts of the matrix around like a stamp?

Farbfetzen commented 4 years ago

Maybe it would be good to instead of using indices just copy parts of the matrix around like a stamp?

Nope, using vector indices is much faster than copying matrices around.