gradOpt.c: merge dos laços do calcGrad

Issue #16

Signed-off-by: Aryane Ast dos Santos <aryaneast@gmail.com>