copied some cuda solver code over