Fix bug in fpdiff when called as a python function

A global variable was leaking into the fpdiff function from the code
executed when fpdiff.py was run as a script. This global relative
difference variable was used instead of the relative difference parameter
passed into the fpdiff function.

Fixed this and moved the script code into a function to prevent global
variables leaking again.
In sumofmatrices add paranoid check and be more consistent with equation number types