rewrite (again) matrix code

Finally accepting static code and required code duplication for
other implementation sizes of matrices and vectors.