check for valid coefficients, fixes #210

Didn't observe any performance hit on the benchmarks. This doesn't address NaN handling in NLP, but in that  case is not strictly an error because sometimes the solver might try to evaluate the function at a bad point.