Move some math headers away from legacyheaders/

- Move nrjac.* to linearalgebra/
- Move do_fit.* to math/

Also some minor associated clean-up.

Change-Id: I11943d5c9a0150133ca0a0d9bc36aceb06fb8bca