I have a function d(x,y,z) that returns the appropriate standard basis vector in 8 dimensions, e.g. d(0,0,0) is the column vector <1,0,0,0,0,0,0,0> and d(0,1,0) is <0,0,1,0,0,0,0,0>. Now, to make a sum over all possible elements, I have tried a sum like this:

sum(sum(sum(a_(i,j,k)*d(i, j, k), k = 0 .. 1), j = 0 .. 1), i = 0 .. 1)

with a_(i,j,k) simply being some coefficient that I want to place in the appropriate position. Basically, I would like to get a column vector: <a_000, a_001, a_010, a_011, a_100, a_101, a_110, a_111>, but the result of the sum above is: <0, 0, 0, 0, 0, 0, 0, a_000 + a_001 + a_010 + a_011 + a_100 + a_101 + a_110 + a_111> instead.

This completely baffles me - it looks like the 'a' coefficients are given the correct indices, but d() is always called with d(1,1,1). Can anyone help? Thank you.