Update ref_matrix.cpp