A Local Construction Of The Smith Normal Form Of A Matrix Polynomial, And Time-Periodic Gravity-Driven Water Waves