change energy_matrix from Mat_ to vector