Ripser / ripser

Ripser: efficient computation of Vietoris–Rips persistence barcodes
http://ripser.org
MIT License
311 stars 78 forks source link

Speed up get_pivot #26

Closed mglisse closed 4 years ago

mglisse commented 4 years ago

Hello, I notice that a common behavior is that get_pivot calls pop_pivot and thus column.pop, just to call column.push on that same value immediately after. This seems like a waste. As an experiment, I inlined the code for pop_pivot in get_pivot, and replaced the test column.empty() with column.size()==1 before pop(). It is possible that I did it wrong, but it gave me a 5% speed-up on the first dataset I tried (o3_2048.txt), which makes it look like a small low-hanging fruit. With a bit more work, it should also be possible to peek at the second "smallest" element without any pop, although I haven't tried it so I don't want to claim that it really helps.

mglisse commented 4 years ago

Uh, I cannot reproduce this now, and I don't see how it could have helped the other day since column.empty() always returns false when pop_pivot is called from get_pivot. And peeking at the second element does not seem to speed up anything. Sorry for the noise.