I would expect the following code to produce a packed 11x11x11 element array of 64 bit integers, but it doesn't:
A = 10;
V = Table[1, {i, 0, 1, 1/A}, {j, 0, 1, 1/A}, {k, 0, 1, 1/A}] ;
Developer`PackedArrayQ[V] (* returns false *)
However, if we just type the stepwise in explicitly, then the array is packed:
V = Table[1, {i, 0, 1, 0.1}, {j, 0, 1, 0.1}, {k, 0, 1, 0.1}] ;
Developer`PackedArrayQ[V] (* returns true *)
What is going on here?
Rationalnumbers cannot be packed.Table[1, {i, 0, 1, 1/10}, {j, 0, 1, 0.1}, {k, 0, 1, 0.1}]is not packed either. The code seems to be analyzed before the subroutine that calculates the table is chosen. With rational or symbolic indices, a non-packing routine is called apparently, at least sometimes. BTW, this seems a better first example:B = 0.1; V = Table[1, {i, 0, 1, 0.1}, {j, 0, 1, 0.1}, {k, 0, 1, B}];because it is clearly equivalent to the second except for the variable in the iterator. And unexpectedly,Table[1, {i, 0, 1, B}, {j, 0, 1, 0.1}, {k, 0, 1, 0.1}]is packed. $\endgroup$V = With[{a=1./A},Table[1, {i, 0,1,a}, {j,0,1,a}, {k,0,1,a}] ];? $\endgroup$