Reputation: 125
I have a 2D Array C[100][10]
,I want to split it column by column and insert in 1D Array like below :
C[100][10]
split to C[0:100][0]
, C[0:100][1]
, ... , C[0:100][10]
and the insert splited arrays to 1D array like : A[100] =C[0:100][0]
I can do all of that with for-loops but take long time and time is critical for my project. is there any way to solve this problem excluding for-loop
Upvotes: 1
Views: 1853
Reputation: 16448
You should use an array of sub arrays like:
std::array<std::array<TYPE, 100>, 10> C;
Then the elements of each sub array are consecutively stored in memory and operations are faster. std::array provides copy operator
std::array<TYPE, 100> A = C[i];
Upvotes: 2