tforgione · GitHub

Hi!

First, thank you for your librairies, they are great!

After investigating the performances of the code from a friend on the forum, I realized that the from_fn function was quite slow due to the fact that matrices are stored by columns, but the iteration is done by rows.

I also added a benchmark to see the performance improvements:

Original version:

test core::matrix::mat100_from_fn :     7,736 ns/iter (+/- 246)
test core::matrix::mat500_from_fn : 1,085,050 ns/iter (+/- 192,820)

This PR version:

test core::matrix::mat100_from_fn:   2,796 ns/iter (+/- 189)
test core::matrix::mat500_from_fn: 650,736 ns/iter (+/- 16,264)

Read the original on github.com ↗