The cubic matrix model and a duality between strings and loops