Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Array Question - Strassens Method - Urgent

Posted on 2003-12-05
7
234 Views
Last Modified: 2010-03-31
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.  
0
Comment
Question by:Akindo
  • 2
  • 2
  • 2
  • +1
7 Comments
 

Author Comment

by:Akindo
ID: 9884020
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??
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 9884198
Looping, AFAIK, can't be avoided, but you can System.arraycopy where there's subarrays, so every single element need not be looped over.
0
 

Author Comment

by:Akindo
ID: 9884446
how would it work for a two dimensional array, say I have

a=2x2
b=2x2
c=2x2
d=2x2

and I want a 4x4 array like
ab
cd
whats the most efficient way to do that?
 
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 92

Expert Comment

by:objects
ID: 9884779
Are you actually using 2d array in your internal representation, and is it that required.
0
 
LVL 2

Expert Comment

by:Tols
ID: 9885449
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 ;-)
0
 
LVL 2

Expert Comment

by:Tols
ID: 9885481
Above class can be modified fo keeping one data for each submatrixes - they shoud keep a range of data in global matrix...
0
 
LVL 92

Expert Comment

by:objects
ID: 9885514
> 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);
}
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 58
How to convert String matching to regex in java 4 49
Configure a Bean in an XML file 4 42
hibernate example issues from command prompt 10 50
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question