linear solver implementation