Added the qn_matrix_update function