Use the nalgebra Cast trait instead of FromPrimitive.