0

I'm wondering what is the best way of calculating the sum of all elements in a matrix in GSL (Gnu scientific library). I don't see any library functions that do this, so will I just need to sum over all the indices myself?

theideasmith
  • 2,835
  • 2
  • 13
  • 20

1 Answers1

0

The fastest a solution can get is O(m*n), so a simple summing iteration over the matrix is the best solution.

theideasmith
  • 2,835
  • 2
  • 13
  • 20
  • If you access the `data` pointer to the elements it can be faster than accessing with two indices. (Still O(m*n)). – alfC Sep 06 '17 at 20:14