I am having an issue with a macro that I am not managing to solve.
The code is messy, but I will try to make clear the issue.
I have the source code here. When I compile this code, the last lines displayed (from expandMacro):
echo [repr [[2.0 * x[3]], [x[3], 0.0], [x[3], 0.0, 0.0], [2.0 * x[0] + x[1] + x[2], x[0], x[0], 0.0]]]
created by this lines.
Basically, obj_hess is typed as seq[seq[NimNode]] and contains a triangular matrix:
[ [2.0 * x[3]], [x[3], 0.0], [x[3], 0.0, 0.0], [2.0 * x[0] + x[1] + x[2], x[0], x[0], 0.0]]]
The problem is when I reference a particular line or item. If I do the following in line 474:
echo repr `obj_hess`[0]
I get the following error:
/home/jose/src/ipopt.nim/src/ipopt.nim(547, 3) template/generic instantiation of `problem` from here /home/jose/src/ipopt.nim/src/ipopt.nim(323, 15) Error: type mismatch: got <array[0..1, Number]> but expected 'array[0..0, float]'
Have you tried writing it
echo repr(`obj_hess`[0])
?for row in `obj_hess`:
for item in row:
values[idx] = obj_factor * item
idx += 1
Which is not working.
It is very strange, because I am using something similar here and it is working. That is what is making me thing that this is an error a not a bug.