Put check for n > 1 AbstractDim in codegen

Wasn't clear how to do the comparison technically correctly, although
the workaround was probably fine.  This is cleaner though.

I didn't test the generated code for correct results from the solver,
just checked that the code generates and in case of C compiles.
Bugfix C codegen

Tried to refactor but messed up generator state.
Merge pull request #39 from chinasaur/ad/1

Put check for n > 1 AbstractDim in codegen