Fix for C89 compilers

In compilers that only support C89 the variables must be declared first. I sometimes have to build in VS2012, where the invdet declaration after the if block causes a build error. Moving that line up fixes the problem.