Updated BFGS minimization routine to use gradient-fn to estimate f-prime

when it is not provided. This also entailed changing gradient-fn to
accept matrices as well as vectors.