Replaced .transpose() with .T
Use CG instead of BFGS for minimizing.
Use cost value and gradient simultaneously.
No more wrapping with lambda function in ex3.