% update gradients from an initial gradient set, such that the updated gradients are evenly distributed.
% INPUT (required)
%   gradCellInitial      :  N_k x 3 gradient matrices, where each row is a point in sphere. k=1,2,...,K
%   param.w              :  weight for single shell term. 0<w<1. 0.5 is the default value.
% INPUT (optional)
%   param.solver         :  'nlopt' (default): use sqp solver (SLSQP) in NLOPT.
%                           'matlab': use fmincon (sqp solver).
%   param.cartesian      :  true (default): use cartesian coordinate (with unit equality constraint);
%                           false: use spherical coordinate (no unit equality constraint).
%   param.localCon       :  0: do not use local constraint
%                           1: use local constraint for the distance between samples in results and samples in initialization to reduce the inequality constraint.
%                              It is faster, and with an appropriate localConAngle, it can obtain the same results as it is set as false.
%                           2 (default): repeat the CNLO with a fixed localConAngle until the result keeps the same.
%   param.localConAngle  :  It is the maximal angular change between samples in results and samples in initialization.
%                           It is used when param.localCon is 1 or 2. The default value is 0.1 radian, if it is not given.
%                           If localConAngle>pi/2, then the result is the same as the results without localCon.
%   gradCell             :  Kx1 cell, each element is a gradient matrix.
% Reference:
%   "Novel single and multiple shell uniform sampling schemes for diffusion MRI using spherical codes",
%   Jian Cheng, Dinggang Shen, Pew-Thian Yap, Peter J. Basser, MICCAI 2015.
% Copyright (c) 2015, Jian Cheng <jian.cheng.1983@gmail.com>