I have function which converts a 1D list to a 3D list, but at the same time when 2nd and 3rd dimension indices are equal it places zeroes instead of values from the input list:
n = 4
input = Table[RandomInteger[5], {i, 1, 48}]
convert[l_] := Table[If[i == j, 0, l[[index++]]], {s, 1, 4}, {i, 1, n}, {j, 1, n}]
output = convert[input]
I’d like to get rid of the Increment[] (++) function.
I think this may work:
Perhaps someone more savvy may help to get rid of the Partition[Partition nasty construction.
HTH!