Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, i`m kinda newbie in programming and i`m stuck into a problem:i have a bidimensional array A of size [M,N] and i need to make another array B of size [M*N,M*N] with the values from the first array and the elements with same indices (for example B[3,1] and B[1,3] ) have the same values. What is the fastest programmable way to to this (it must be as faster as it can,because it will work with thousands of numbers)
Posted
Updated 10-Apr-12 3:29am
v2
Comments
Dr.Walt Fair, PE 9-Apr-12 19:11pm    
What algorithm or formula do you need to apply to get the new M*N x M*N matrix from the old A[M*N]? If you don't require any particular formula, there are a multitude of ways to do that, the easiest being to just create an M*N x M*N dimensioned array and fill it with something like 0.

However, I suspect that's not what you meant, so you need to clarify what formula needs to be used.
Sergey Alexandrovich Kryukov 29-May-12 13:19pm    
The problem is well solved using Array.Copy -- I answered.
--SA

1 solution

To accelerate things and avoid element-by-element cloning, use Array.Copy methods. Please see:
http://msdn.microsoft.com/en-us/library/system.array.copy%28v=vs.100%29.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900