Fix nonlinearprogram

1. Previously `NonlinearProgram` gives incorrect gradient if the `xind` in `addConstraint` contains duplicate variables, for example
```
cnstr = FunctionHandleConstraint(-1,1,2,@(x,y) x+y);
prog = prog.addNonlinearConstraint(cnstr,[1;1])
```
I fix this in a not very clean way (uses for loop)
2. If we add an empty linear constraint in `NonlinearProgram` and then delete it, the program will fail. Now it accepts empty linear constraint.
We can throw an error, and we will require that the input `xind` are all
different, the non-uniqueness definitely makes the problem a lot worse.
Some of our code passes non-unique `xind`, and the constraint gradient was
wrong.

I can throw an error here if you think that is a better solution.

On Thu, Dec 4, 2014 at 6:55 AM, Russ Tedrake <notifications@github.com>
wrote:

> In solvers/NonlinearProgram.m:
>
> > @@ -313,6 +319,12 @@
> >        obj.num_ceq = obj.num_ceq + length(cnstr.ceq_idx);
> >        obj.nlcon_xind{end+1} = xind;
> >        obj.nlcon_xind_stacked{end+1} = xind_vec;
> > +      if(length(unique(xind_vec)) ~= length(xind_vec))
> > +        warning('Drake:NonlinearProgram:DuplicateVarNLcon','The input nonlinear constraint has the same decision variable being used duplicatedly as input argument, for example f(x,x) = x+x, consider to combine the input argument to remove the duplicity, by writing f(x) = 2*x');
>
> should this just be an error? why support it?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/RobotLocomotion/drake/pull/594/files#r21299980>.
>