complete Cmp based on matrix