improvement of matrix wide operations such as sum and prod