1. ## Duplicating arrays

Hi!!

This is my first post on the forum, because I've been having trouble trying to do this. How can I from an array that's [i][j] duplicate it's column and line values to a [2*i][2*j]?
For example : [2,4];[5,6] to [2,2,4,4];[2,2,4,4];[5,5,6,6];[5,5,6,6]
And how can I do the inverse, remove alternatively column and line.
For example: [1,2,3,4];[5,6,7,8];[9,10,11,12];[13,14,15,16] to [1,3];[9,11]

Thanks!

2. Just do newArray[i][j] = oldArray[i/2][j/2] for each i, j.

___________
Visit my project: Online symbolic derivative calculator

3. Originally Posted by TomasRiker
Just do newArray[i][j] = oldArray[i/2][j/2] for each i, j.
That covers the second case.
For the first case you want to assign each value to the four locations:
[i*2][j*2]
[i*2+1][j*2]
[i*2][j*2+1]
[i*2+1][j*2+1]

4. Originally Posted by TomasRiker
Just do newArray[i][j] = oldArray[i/2][j/2] for each i, j.
First case is working, as for the second case tried and it doesn't work and I can't understand why it puts the new array all with 1's plus it alters the first row of the original one.

5. Originally Posted by interneft
First case is working, as for the second case tried and it doesn't work and I can't understand why it puts the new array all with 1's plus it alters the first row of the original one.
Actually, my mistake, the other guy's suggestion was also for the first case, and is probably the simpler way of doing it.
For the second case you can just turn the /2 into *2.