Lie-algebraic conditions for exponential stability of switched systems