creeping towards making it compile. lots of careless mistakes, and some template nonsense I'm learning about.
Fixed up all the bugs found so far. Some careless arthmetic errors, and a few typos.
tidied up the test, ready for adding a lot more