use rank instead of eigenvalues to test for singularity
use sizes for matrices when they are known, to get the advantages of compile-time checking and work around some (seeming) Eigen issues