Matrix groups and Lie algebras: an algebraic treatment