An algebraic algorithm for non-commutative rank over any field