Updated test for autodiff, using matrix dictionary