initial import factorization tools

this is unnecessarily complicated since the inverse field is never seen outside of this function, so we can call it what we like, __inv__ or someting