I have 3 functions as below
N1 = 4; N2 = 5; N3 = 7;
g1[n1_] := (N1 - 3 n1 - 1)/N1;
g2[n2_] := (N1 - 3 n2 - 1)/N1;
g3[n3_] := (N1 - 3 n3 - 1)/N1;
list1 = g1 /@ Range[1, N1];
list2 = g2 /@ Range[1, N2];
list3 = g3 /@ Range[1, N3];
I must create a matrix whose elements are randomly selected elements of these lists as exemplified by the sketch below:(each row is not repeated twice or more)
matrix1 = ConstantArray[0, {N1*N2*N3, 4}];
For example below sketch shows some verified permutations-
In particular, the fourth element in each row is the norm of the three preceding elements in the same row.
Without respect to the fourth elements in each row the below code which is not correct can partially satisfy the aim
matrix1 = ConstantArray[0, {N1*N2*N3, 4}];
Do[
Do[
Do[
matrix1[[i, 1]] = list1[[If[Mod[i, 4] != 0, Mod[i, 4], 4]]];
matrix1[[j, 2]] = list2[[If[Mod[j, 5] != 0, Mod[j, 5], 5]]];
matrix1[[k, 3]] = list3[[If[Mod[k, 7] != 0, Mod[k, 7], 7]]];
, {i, 1, 140}],
{j, 1, 140}],
{k, 1, 140}]
The speed of above code is very slow!