Generalized Time Warping Invariant Dictionary Learning for Time Series Classification and Clustering