Array Question - Strassens Method - Urgent

Say Im implementing Strassens method for an array that is larger than 2x2(say 4x4 n=4). And say I calculated each sub array correctly (the 4 n/2 pieces) and I want to construct the new nxn matrix that holds the solution. Whats the easiest/most efficient way to reconstruct a larger array from the smaller pieces, just a for loop or is there something easier.  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AkindoAuthor Commented:
Also, on the opp side of the question whats the easiest way to deconstruct the array in 4 n/2 pieces, basically the 4 quadrants...also a double for loop??
Looping, AFAIK, can't be avoided, but you can System.arraycopy where there's subarrays, so every single element need not be looped over.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AkindoAuthor Commented:
how would it work for a two dimensional array, say I have


and I want a 4x4 array like
whats the most efficient way to do that?
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Mick BarryJava DeveloperCommented:
Are you actually using 2d array in your internal representation, and is it that required.
Maybe some tree structure coud simplify that;

class Matrix
     Matrix parent;
     int leafValue = null;
     Matrix[][] children = null; //could be ArrayList
     public Matrix(Matrix parent, int leafValue) //for leafs
         this.parent = parent;
         this leafValue = leafValue;
     public Matrix(Matrix parent) //for nodes
         this.parent = parent;
     public int getValue() //possible modification for other data
         if (children == null) return leafValue;
         //calculate value of submatrix
         int val = children[0][0].getValue()+children[1][1].getValue() ....//recurrent calls
         return val;


I hope it help ;-)
Above class can be modified fo keeping one data for each submatrixes - they shoud keep a range of data in global matrix...
Mick BarryJava DeveloperCommented:
> and I want a 4x4 array like
> ab
> cd

int[][] result = new int[4][4];
for (int i=0; i<2; i++)
   System.arraycopy(a[i], 0, result[i], 0, 2);
   System.arraycopy(b[i], 0, result[i], 2, 2);
   System.arraycopy(c[i], 0, result[i+2], 0, 2);
   System.arraycopy(d[i], 0, result[i+2], 2, 2);
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.