last attempt with the templated version... I'm going to try to do it without templates like the dense one does it.
seg fault debugging
debugging seg fault