On matrices having an invariant cone