put timing code in
Can now calculate gradient for 2 or 3 dimensions
Added a bit more documentation