|
Does anyone know if there is a way to produce a 2D array from a 1D array, where the rows in the 2D are generated by repeating the corresponding elements in the 1D array.
I.e.:
1D array 2D array |1| |1 1 1 1 1| |2| |2 2 2 2 2| |3| -> |3 3 3 3 3| |4|...
Started by Chris on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You can do this using the REPMAT function:
>> A = (1:5).' A = 1 2 3 4 5 >> B = repmat(A,1,5) B = 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5
EDIT: BONUS ANSWER! ;)
For your example, REPMAT is the most straight-forward function to use... .
|
|
Hey everyone,
When implementing a Matrix construct using arrays, which would be more efficient? Using a 1D array, or an array of arrays (2D)?
I would think a 2D is more efficient as you already have the X and Y coordinates of an element, where in a 1D...
Started by barfoon on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
I'm talking of the construct:
int x[9][9];
A 1D array of the form:
int x[81];
is unlikely to be any (which will require two memory accesses as opposed to the one required for a 1D array) so the 1D array with the answers to date ....
|
|
I want to represent a 2D array with a 1D array. A function will pass the two indicies (x,y) and the value to store. These two indicies would represent a single element of a 1D array, and set it accordingly. I know the 1D array needs to be (arrayWidth ...
Started by Blackbinary on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
; }
The typical formula for recalculation of 2D array indices into 1D array index is
index = indexX * arrayWidth.
|
Ask your Facebook Friends
|
Possible Duplicates:
Implementing a matrix, which is more efficient - using an Array of Arrays (2D) or a 1D array?
Performance of 2-dimensional array vs 1-dimensional array
I was looking at one of my buddy's molecular dynamics code bases the other day...
Started by Casey on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
The first case obviously has no performance penalty compared to a 1D array, because it is identical to....
Sometimes 2D arrays are implemented by a 1D array of pointers to 1D arrays.
Often 2D arrays are implemented as 1D arrays.
|
|
I have two arrays for a chess variant I am coding in java...I have a console version so far which represents the board as a 1D array (size is 32) but I am working on making a GUI for it and I want it to appear as a 4x8 grid, so I have a 2-dimensional ...
Started by Becky on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I gives which row you are in, and j gives the column (how far .
End to end in your 1D array.
|
|
I have an array of float rtmp1[NMAX * 3][3], and it is used as rtmp1[i][n], where n is from 0 to 2, and i is from 0 to 3 * NMAX - 1. However, I would like to convert rtmp1 to be rtmp1[3 * 3 * NMAX]. Would addressing this new 1D array as rtmp1[3 * i + ...
Started by stanigator on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I'm not ....
"Actually, you'd want to use rtmp[i + 3*n]" what is the difference? All you are doing is swapping addresses .
Yes, but what are you trying to prove by doing this? rtmp1[i][n] would most likely have better execution time and is easier to read .
|
|
If I have a 1 dimensional array of data such as this:
1 2 3 4 5 6 7 8 9 1
and a corresponding data access table:
0 2 5 8
How would I print the 2D diagonalized array below with the zeros?
1 2 0 0 3 4 5 0 0 6 7 8 0 0 9 1
Code would be very helpful. Thanks...
Started by Andrew on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
So the 1 2.
The data access table just tells you where each row of data is put in the 1D array.
|
|
Thinking of buying a pair of a&h xone 1d's to go with torq 2.0. Can i control all 4 decks in torq with 2 1D's using some sort of switch deck button? Has anybody here used them with torq? Is it possible to map the jogwheel on one 1d to control the waveforms...
Started by scott on
, 11 posts
by 8 people.
Answer Snippets (Read the full thread at torq-dj):
I ....
According to the forums here, even though a controller is officially supported, some features may not be fully functional .
One more question, is there an 'active deck' feature in 2.0? So i could map the controls on the 1D with the 1d.
|
|
Topic created to show all 1d kangaroo flaws, listed and unlisted, all in one place.
To provide a census of number of 1d kangaroo flaws.
Please copy your 1d kangaroo flaws from other topics.
ACSC 2(A)f Diagonal white scratch from first "A" to coast of ...
Started by austcollect on
, 13 posts
by 6 people.
Answer Snippets (Read the full thread at stampboards):
And I`ve heard of the cherry-red 1d Kangaroo, which was also sold in the Gray sale paper variety known for 1d reds....
I have seen that there are four different shades of the 1d red about them.
I thought I`d give this thread a bump.
|
|
正1D,反正1D,反负1D
近日见到新增术语:正1D,反正1D,反负1D
正1D:正1D = (百+十的和值尾数)+ (十+个的和值尾数)的和值尾数。例如761这个号码的正1D值的计算方式为:7+6=13,其尾数为3;6+1=7,其尾数为7;两个尾数相加3+7=10,其尾数为0,所以761的正1D值就是0。
负1D:负1D = (百-十的绝对值)- (十-个的绝对值)的绝对值。例如761这个号码的负1D值的计算方式为:|7-6|=1,|6-1|=5,|1-5|=4,所以761的负1D值就是4。
反正...
Answer Snippets (Read the full thread at prlweb):
我刚进入状态,
正是好学时。
希望读帖高手无私赐教! 听课学习,谢!
掌上冲浪,我用UCWEB手机浏览器 不懂有什么用处,现学习再看 不懂有什么用处,现学习再看 这样的算法你可以自己弄出无数种
很多都是循环的
没有太大实用价值
其实质就是不同的号码组
不同的角度
去看同样的号
关键在于如何把握号码本身的走势
否则无论如何变化都是一脸茫然
除了组合方式的新颖带来的新鲜感外
对技术本身没有太多弥补作用 原帖由 无间 于 2007-2-1 12:40 发表
这样的算法你可以自己弄出无数种
很多都是循环的... .
|