c++ template linear iterative solver