Add function to convert between heterogeneous and homogeneous vectors