I have an array X(9,2) and I want to generate another array B(512,9) with all the possible combinations.
I thought about doing 9 do loops, but I was hoping for a more efficient way.
This is what I have
Is there something wrong with this? Is there a better way of doing it?
Thanks!
I thought about doing 9 do loops, but I was hoping for a more efficient way.
This is what I have
Code:
do i1=1, 2
do i2=1, 2
do i3=1,2
do i4=1,2
do i5=1,2
do i6=1,2
do i7=1,2
do i8=i,2
do i9=1,2
B(row, col) = X(1,i1)
col = col + 1
B(row, col) = X(2,i2)
col = col + 1
B(row, col) = X(3,i3)
col = col + 1
B(row, col) = X(4,i4)
col = col + 1
B(row, col) = X(5,i5)
col = col + 1
B(row, col) = X(6,i6)
col = col + 1
B(row, col) = X(7,i7)
col = col + 1
B(row, col) = X(8,i8)
col = col + 1
B(row, col) = X(9,i9)
col = 1
row = row + 1
end do
end do
end do
end do
end do
end do
end do
end do
end do
Thanks!