Invariants of polynomial matrices