Why can't nested list be packed?
In[252]:= ftest = {1., {3.}};
ftest = Developer`ToPackedArray[ftest];
Developer`PackedArrayQ[ftest]
Out[254]= False
Why can't nested list be packed?
In[252]:= ftest = {1., {3.}};
ftest = Developer`ToPackedArray[ftest];
Developer`PackedArrayQ[ftest]
Out[254]= False
Per J.M.'s and Dr. Belisarius's comment:
Only tensors passing ArrayQ can be packed. Any of {{1.}, {3.}}, {{1., 3.}}, and {1., 3.} can be packed, but ragged, non-rectangular lists (e.g. {{1, 2}, {3, 4, 5}} or {1, {2}, 3}) cannot.
"Packed arrays are a representation for rectangular tensors of machine integers, machine reals, and complex numbers with real and imaginary parts that are machine reals"
lists = N@{
{{1}, {3}},
{{1, 3}},
{1, 3},
{1},
{1, 2},
{1, {2}, 3},
{{1, 2}, {3, 4, 5}}
};
ArrayQ /@ lists
packed = Developer`ToPackedArray /@ lists;
Developer`PackedArrayQ /@ packed
{True, True, True, True, True, False, False} (* ArrayQ *){True, True, True, True, True, False, False} (* PackedArrayQ *)
from the documentation.
ArrayQ[]) can be packed.{{1.}, {3.}},{{1., 3.}}, and{1., 3.}can all be packed, but yours can't. – J. M.'s missing motivation Mar 30 '16 at 05:07