leq: Generalize template arguments.

Where applicable, functions are templated on all different inputs.
leq: Fix inv().

Required a const-cast to make gauss_elim happy. Use Derived instead of
MatrixBase to avoid setIdentity() inf loop.