Add swap support for dyn_matrix