removed parfor loops

I removed the parfor loops in both the cost and the gradient of the cost because I don't want to assume that the parallelization package is available.